Skip to content

Commit 80dbf18

Browse files
fix: parse percent-encoding url (#136)
1 parent 1227d60 commit 80dbf18

File tree

7 files changed

+1258
-884
lines changed

7 files changed

+1258
-884
lines changed

package-lock.json

+1,226-882
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@
7070
"npm-run-all": "^4.1.5",
7171
"prettier": "^2.1.2",
7272
"standard-version": "^9.0.0",
73-
"webpack": "^5.2.0"
73+
"webpack": "^5.9.0"
7474
},
7575
"keywords": [
7676
"webpack"

src/utils.js

+5-1
Original file line numberDiff line numberDiff line change
@@ -87,8 +87,12 @@ function getSourceMappingURL(code) {
8787
}
8888
}
8989

90+
const sourceMappingURL = match ? match[1] || match[2] || '' : null;
91+
9092
return {
91-
sourceMappingURL: match ? match[1] || match[2] || '' : null,
93+
sourceMappingURL: sourceMappingURL
94+
? decodeURI(sourceMappingURL)
95+
: sourceMappingURL,
9296
replacementString: match ? match[0] : null,
9397
};
9498
}

test/__snapshots__/loader.test.js.snap

+10
Original file line numberDiff line numberDiff line change
@@ -334,6 +334,16 @@ Object {
334334

335335
exports[`source-map-loader should process inlined sources: warnings 1`] = `Array []`;
336336

337+
exports[`source-map-loader should process percent-encoding path: css 1`] = `
338+
"with SourceMap
339+
// comment
340+
"
341+
`;
342+
343+
exports[`source-map-loader should process percent-encoding path: errors 1`] = `Array []`;
344+
345+
exports[`source-map-loader should process percent-encoding path: warnings 1`] = `Array []`;
346+
337347
exports[`source-map-loader should process protocol-relative-url-path: css 1`] = `
338348
"// Some content
339349
// # sourceMappingURL=//sampledomain.com/external-source-map2.map

test/fixtures/{percent}.js

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
with SourceMap
2+
// #sourceMappingURL=%7Bpercent%7D.js.map
3+
// comment

test/fixtures/{percent}.js.map

+1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

test/loader.test.js

+12
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,18 @@ describe('source-map-loader', () => {
5151
expect(getErrors(stats)).toMatchSnapshot('errors');
5252
});
5353

54+
it('should process percent-encoding path', async () => {
55+
const testId = '{percent}.js';
56+
const compiler = getCompiler(testId);
57+
const stats = await compile(compiler);
58+
const codeFromBundle = getCodeFromBundle(stats, compiler);
59+
60+
expect(codeFromBundle.map).toBeDefined();
61+
expect(codeFromBundle.css).toMatchSnapshot('css');
62+
expect(getWarnings(stats)).toMatchSnapshot('warnings');
63+
expect(getErrors(stats)).toMatchSnapshot('errors');
64+
});
65+
5466
it('should process external SourceMaps', async () => {
5567
const testId = 'external-source-map.js';
5668
const compiler = getCompiler(testId);

0 commit comments

Comments
 (0)