Skip to content
This repository was archived by the owner on Jul 13, 2020. It is now read-only.

Commit d47a503

Browse files
committed
add url whitespace trim to resolve
1 parent f2bb139 commit d47a503

File tree

2 files changed

+4
-0
lines changed

2 files changed

+4
-0
lines changed

core/resolve.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ function throwResolveError () {
77
throw new RangeError('Unable to resolve "' + relUrl + '" to ' + parentUrl);
88
}
99
export function resolveIfNotPlain (relUrl, parentUrl) {
10+
relUrl = relUrl.trim();
1011
var parentProtocol = parentUrl && parentUrl.substr(0, parentUrl.indexOf(':') + 1);
1112

1213
var firstChar = relUrl[0];

test/1-url-resolution.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@ import { resolveIfNotPlain } from '../core/resolve.js';
22
import assert from 'assert';
33

44
describe('Simple normalization tests', function() {
5+
it('Should trim whitespace from URLs', function () {
6+
assert.equal(resolveIfNotPlain(' c:\\some\\path ', 'file:///c:/adsf/asdf'), 'file:///c:/some/path');
7+
});
58
it('Should resolve windows paths as file:/// URLs', function() {
69
assert.equal(resolveIfNotPlain('c:\\some\\path', 'file:///c:/adsf/asdf'), 'file:///c:/some/path');
710
});

0 commit comments

Comments
 (0)