Skip to content

Commit 582f8dc

Browse files
zuohaochengjoshwiens
authored andcommitted
fix: Regex does not work for minified artifact of style-loader (#39)
1 parent 554d4fb commit 582f8dc

File tree

3 files changed

+3
-3
lines changed

3 files changed

+3
-3
lines changed

index.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ var async = require("async");
99
var loaderUtils = require("loader-utils");
1010

1111
// Matches only the last occurrence of sourceMappingURL
12-
var baseRegex = "\\s*[@#]\\s*sourceMappingURL\\s*=\\s*([^\\s]*)(?![\S\s]*sourceMappingURL)",
12+
var baseRegex = "\\s*[@#]\\s*sourceMappingURL\\s*=\\s*([^\\s]*)(?![\\S\\s]*sourceMappingURL)",
1313
// Matches /* ... */ comments
1414
regex1 = new RegExp("/\\*"+baseRegex+"\\s*\\*/"),
1515
// Matches // .... comments

test/fixtures/multi-source-map.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
with SourceMap
2-
anInvalidDirective = "\n/*# sourceMappingURL=data:application/json;base64," + btoa(unescape(encodeURIComponent(JSON.stringify(sourceMap)))) + " */";
2+
anInvalidDirective = "\n/*# sourceMappingURL=data:application/json;base64,"+btoa(unescape(encodeURIComponent(JSON.stringify(sourceMap))))+" */";
33
// @ sourceMappingURL = data:application/source-map;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5saW5lLXNvdXJjZS1tYXAuanMiLCJzb3VyY2VzIjpbImlubGluZS1zb3VyY2UtbWFwLnR4dCJdLCJzb3VyY2VzQ29udGVudCI6WyJ3aXRoIFNvdXJjZU1hcCJdLCJtYXBwaW5ncyI6IkFBQUEifQ==
44
// comment

test/index.test.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ describe("source-map-loader", function() {
113113
execLoader(path.join(__dirname, "fixtures", "multi-source-map.js"), function (err, res, map, deps, warns) {
114114
should.equal(err, null);
115115
warns.should.be.eql([]);
116-
should.equal(res, "with SourceMap\nanInvalidDirective = \"\\n/*# sourceMappingURL=data:application/json;base64,\" + btoa(unescape(encodeURIComponent(JSON.stringify(sourceMap)))) + \" */\";\n// comment"),
116+
should.equal(res, "with SourceMap\nanInvalidDirective = \"\\n/*# sourceMappingURL=data:application/json;base64,\"+btoa(unescape(encodeURIComponent(JSON.stringify(sourceMap))))+\" */\";\n// comment"),
117117
map.should.be.eql({
118118
"version": 3,
119119
"file": "inline-source-map.js",

0 commit comments

Comments
 (0)