Skip to content

Commit c124fae

Browse files
fix: handling \ character (#353)
1 parent b13892b commit c124fae

File tree

6 files changed

+268
-53
lines changed

6 files changed

+268
-53
lines changed

src/utils.js

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -370,13 +370,17 @@ export function parseSrc(input) {
370370
return { value, startIndex };
371371
}
372372

373-
export function normalizeUrl(url) {
374-
return decodeURI(url).replace(/[\t\n\r]/g, '');
375-
}
376-
377373
const moduleRequestRegex = /^[^?]*~/;
378374
const matchNativeWin32Path = /^[A-Z]:[/\\]|^\\\\/i;
379375

376+
export function normalizeUrl(url) {
377+
return matchNativeWin32Path.test(url)
378+
? decodeURI(url).replace(/[\t\n\r]/g, '')
379+
: decodeURI(url)
380+
.replace(/[\t\n\r]/g, '')
381+
.replace(/\\/g, '/');
382+
}
383+
380384
export function requestify(url) {
381385
if (matchNativeWin32Path.test(url) || url[0] === '/') {
382386
return url;

test/__snapshots__/esModule-option.test.js.snap

Lines changed: 36 additions & 6 deletions
Large diffs are not rendered by default.

test/__snapshots__/loader.test.js.snap

Lines changed: 12 additions & 2 deletions
Large diffs are not rendered by default.

test/__snapshots__/minimize-option.test.js.snap

Lines changed: 54 additions & 12 deletions
Large diffs are not rendered by default.

test/__snapshots__/sources-option.test.js.snap

Lines changed: 152 additions & 28 deletions
Large diffs are not rendered by default.

test/fixtures/simple.html

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -436,4 +436,9 @@ <h2>An Ordered HTML List</h2>
436436

437437
<meta itemprop="a" content="./image.png" />
438438
<meta itemprop="b" content="./image.png" />
439-
<meta itemprop=" " content="./image.png" />
439+
<meta itemprop=" " content="./image.png" />
440+
441+
<img src='.\nested\image3.png' />
442+
<img src='\nested\image3.png' />
443+
<img src='/nested\image3.png' />
444+
<img src='nested\image3.png' />

0 commit comments

Comments
 (0)