From 2572a2ff7ddd3ae920c7aeeaf64143357f6b1646 Mon Sep 17 00:00:00 2001 From: Sergey Vohmyanin Date: Tue, 11 Oct 2022 00:00:12 +0300 Subject: [PATCH] feat: Make comment RegExps non-greedy to prevent some max call stack errors (#65) --- index.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/index.js b/index.js index dc602d7..b82f6dc 100644 --- a/index.js +++ b/index.js @@ -4,14 +4,14 @@ var path = require('path'); Object.defineProperty(exports, 'commentRegex', { get: function getCommentRegex () { - return /^\s*\/(?:\/|\*)[@#]\s+sourceMappingURL=data:(?:application|text)\/json;(?:charset[:=]\S+?;)?base64,(?:.*)$/mg; + return /^\s*?\/(?:\/|\*?)[@#]\s+?sourceMappingURL=data:(?:application|text)\/json;(?:charset[:=]\S+?;)?base64,(?:.*?)$/mg; } }); Object.defineProperty(exports, 'mapFileCommentRegex', { get: function getMapFileCommentRegex () { // Matches sourceMappingURL in either // or /* comment styles. - return /(?:\/\/[@#][ \t]+sourceMappingURL=([^\s'"`]+?)[ \t]*$)|(?:\/\*[@#][ \t]+sourceMappingURL=([^\*]+?)[ \t]*(?:\*\/){1}[ \t]*$)/mg; + return /(?:\/\/[@#][ \t]+?sourceMappingURL=([^\s'"`]+?)[ \t]*?$)|(?:\/\*[@#][ \t]+sourceMappingURL=([^*]+?)[ \t]*?(?:\*\/){1}[ \t]*?$)/mg; } });