Skip to content

Commit

Permalink
fix: handling \ character (#353)
Browse files Browse the repository at this point in the history
  • Loading branch information
cap-Bernardito committed Feb 11, 2021
1 parent b13892b commit c124fae
Show file tree
Hide file tree
Showing 6 changed files with 268 additions and 53 deletions.
12 changes: 8 additions & 4 deletions src/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -370,13 +370,17 @@ export function parseSrc(input) {
return { value, startIndex };
}

export function normalizeUrl(url) {
return decodeURI(url).replace(/[\t\n\r]/g, '');
}

const moduleRequestRegex = /^[^?]*~/;
const matchNativeWin32Path = /^[A-Z]:[/\\]|^\\\\/i;

export function normalizeUrl(url) {
return matchNativeWin32Path.test(url)
? decodeURI(url).replace(/[\t\n\r]/g, '')
: decodeURI(url)
.replace(/[\t\n\r]/g, '')
.replace(/\\/g, '/');
}

export function requestify(url) {
if (matchNativeWin32Path.test(url) || url[0] === '/') {
return url;
Expand Down
42 changes: 36 additions & 6 deletions test/__snapshots__/esModule-option.test.js.snap

Large diffs are not rendered by default.

14 changes: 12 additions & 2 deletions test/__snapshots__/loader.test.js.snap

Large diffs are not rendered by default.

66 changes: 54 additions & 12 deletions test/__snapshots__/minimize-option.test.js.snap

Large diffs are not rendered by default.

180 changes: 152 additions & 28 deletions test/__snapshots__/sources-option.test.js.snap

Large diffs are not rendered by default.

7 changes: 6 additions & 1 deletion test/fixtures/simple.html
Original file line number Diff line number Diff line change
Expand Up @@ -436,4 +436,9 @@ <h2>An Ordered HTML List</h2>

<meta itemprop="a" content="./image.png" />
<meta itemprop="b" content="./image.png" />
<meta itemprop=" " content="./image.png" />
<meta itemprop=" " content="./image.png" />

<img src='.\nested\image3.png' />
<img src='\nested\image3.png' />
<img src='/nested\image3.png' />
<img src='nested\image3.png' />

0 comments on commit c124fae

Please sign in to comment.