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

Commit d141492

Browse files
committed
add percent encoding for locate
1 parent ec44a82 commit d141492

File tree

6 files changed

+33
-3
lines changed

6 files changed

+33
-3
lines changed

dist/es6-module-loader-sans-promises.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1325,6 +1325,15 @@ function logloads(loads) {
13251325
if (wildcard)
13261326
outPath = outPath.replace('*', wildcard);
13271327

1328+
// percent encode each path part
1329+
if (isBrowser) {
1330+
var outParts = outPath.split('/');
1331+
for (var i = 0, l = outParts.length; i < l; i++) {
1332+
outParts[i] = encodeURIComponent(outParts[i]);
1333+
}
1334+
outPath = outParts.join('/');
1335+
}
1336+
13281337
return toAbsoluteURL(this.baseURL, outPath);
13291338
},
13301339
fetch: function(load) {

dist/es6-module-loader-sans-promises.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/es6-module-loader.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2499,6 +2499,15 @@ function logloads(loads) {
24992499
if (wildcard)
25002500
outPath = outPath.replace('*', wildcard);
25012501

2502+
// percent encode each path part
2503+
if (isBrowser) {
2504+
var outParts = outPath.split('/');
2505+
for (var i = 0, l = outParts.length; i < l; i++) {
2506+
outParts[i] = encodeURIComponent(outParts[i]);
2507+
}
2508+
outPath = outParts.join('/');
2509+
}
2510+
25022511
return toAbsoluteURL(this.baseURL, outPath);
25032512
},
25042513
fetch: function(load) {

dist/es6-module-loader.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/system.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -200,6 +200,15 @@
200200
if (wildcard)
201201
outPath = outPath.replace('*', wildcard);
202202

203+
// percent encode each path part
204+
if (isBrowser) {
205+
var outParts = outPath.split('/');
206+
for (var i = 0, l = outParts.length; i < l; i++) {
207+
outParts[i] = encodeURIComponent(outParts[i]);
208+
}
209+
outPath = outParts.join('/');
210+
}
211+
203212
return toAbsoluteURL(this.baseURL, outPath);
204213
},
205214
fetch: function(load) {

test/test.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,10 @@ function runTests() {
144144

145145
System.baseURL = 'http://example.org/a/';
146146

147-
test('Locate', System.locate({ name: '@abc/def' }), 'http://example.org/a/@abc/def.js');
147+
if (typeof window != 'undefined')
148+
test('Locate', System.locate({ name: '@abc/def' }), 'http://example.org/a/%40abc/def.js');
149+
else
150+
test('Locate', System.locate({ name: '@abc/def' }), 'http://example.org/a/@abc/def.js');
148151
test('Locate', System.locate({ name: 'abc/def' }), 'http://example.org/a/abc/def.js');
149152

150153
// paths

0 commit comments

Comments
 (0)