Skip to content

Commit 5968493

Browse files
fix: parse percent-encoding url
1 parent 2d0d27d commit 5968493

File tree

3 files changed

+18
-14
lines changed

3 files changed

+18
-14
lines changed

src/utils.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,8 @@ async function fetchFromFilesystem(loaderContext, sourceURL) {
129129

130130
try {
131131
buffer = await new Promise((resolve, reject) => {
132-
loaderContext.fs.readFile(sourceURL, (error, data) => {
132+
// eslint-disable-next-line global-require
133+
require('fs').readFile(sourceURL, (error, data) => {
133134
if (error) {
134135
return reject(error);
135136
}
Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,11 @@
11
// Jest Snapshot v1, https://goo.gl/fbAQLP
22

3-
exports[`source-map-loader should process percent-encoding path: FILE_CONTENT 1`] = `
3+
exports[`source-map-loader should process percent-encoding path: css 1`] = `
44
"with SourceMap
5-
// #sourceMappingURL=%7Bpercent%7D.js.map
65
// comment
76
"
87
`;
8+
9+
exports[`source-map-loader should process percent-encoding path: errors 1`] = `Array []`;
10+
11+
exports[`source-map-loader should process percent-encoding path: warnings 1`] = `Array []`;

test/loader.test.js

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -53,19 +53,19 @@ describe('source-map-loader', () => {
5353

5454
it.only('should process percent-encoding path', async () => {
5555
const testId = '{percent}.js';
56-
// const compiler = getCompiler(testId);
57-
// const stats = await compile(compiler);
58-
// const codeFromBundle = getCodeFromBundle(stats, compiler);
59-
60-
const file = path.resolve(__dirname, 'fixtures', testId);
61-
const fileContent = fs.readFileSync(file);
56+
const compiler = getCompiler(testId);
57+
const stats = await compile(compiler);
58+
const codeFromBundle = getCodeFromBundle(stats, compiler);
6259

63-
expect(fileContent.toString()).toMatchSnapshot('FILE_CONTENT');
60+
// const file = path.resolve(__dirname, 'fixtures', testId);
61+
// const fileContent = fs.readFileSync(file);
62+
//
63+
// expect(fileContent.toString()).toMatchSnapshot('FILE_CONTENT');
6464

65-
// expect(codeFromBundle.map).toBeDefined();
66-
// expect(codeFromBundle.css).toMatchSnapshot('css');
67-
// expect(getWarnings(stats)).toMatchSnapshot('warnings');
68-
// expect(getErrors(stats)).toMatchSnapshot('errors');
65+
expect(codeFromBundle.map).toBeDefined();
66+
expect(codeFromBundle.css).toMatchSnapshot('css');
67+
expect(getWarnings(stats)).toMatchSnapshot('warnings');
68+
expect(getErrors(stats)).toMatchSnapshot('errors');
6969
});
7070

7171
it('should process external SourceMaps', async () => {

0 commit comments

Comments
 (0)