File tree Expand file tree Collapse file tree 2 files changed +9
-1
lines changed Expand file tree Collapse file tree 2 files changed +9
-1
lines changed Original file line number Diff line number Diff line change @@ -181,7 +181,7 @@ export default function normalizeUrl(urlString, options) {
181
181
// Decode URI octets
182
182
if ( urlObject . pathname ) {
183
183
try {
184
- urlObject . pathname = decodeURI ( urlObject . pathname ) ;
184
+ urlObject . pathname = decodeURI ( urlObject . pathname ) . replace ( / \\ / g , '%5C' ) ;
185
185
} catch { }
186
186
}
187
187
Original file line number Diff line number Diff line change @@ -417,3 +417,11 @@ test('ignore custom schemes', t => {
417
417
t . is ( normalizeUrl ( 'sindre://www.sindresorhus.com' ) , 'sindre://www.sindresorhus.com' ) ;
418
418
t . is ( normalizeUrl ( 'foo:bar' ) , 'foo:bar' ) ;
419
419
} ) ;
420
+
421
+ test ( 'encoded backslashes do not get decoded' , t => {
422
+ t . is ( normalizeUrl ( 'https://foo.com/some%5Bthing%5Celse/that-is%40great@coding' ) , 'https://foo.com/some[thing%5Celse/that-is%40great@coding' ) ;
423
+ t . is ( normalizeUrl ( 'https://foo.com/something%5Celse/great' ) , 'https://foo.com/something%5Celse/great' ) ;
424
+
425
+ // Non-encoded backslashes should remain as-is.
426
+ t . is ( normalizeUrl ( 'https://foo.com/something\\else/great' ) , 'https://foo.com/something/else/great' ) ;
427
+ } ) ;
You can’t perform that action at this time.
0 commit comments