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

Commit b583464

Browse files
committed
only percent encode #
1 parent d9697df commit b583464

File tree

2 files changed

+7
-12
lines changed

2 files changed

+7
-12
lines changed

lib/system.js

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -200,14 +200,12 @@
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-
}
203+
// percent encode just '#' in module names
204+
// according to https://github.com/jorendorff/js-loaders/blob/master/browser-loader.js#L238
205+
// we should encode everything, but it breaks for servers that don't expect it
206+
// like in (https://github.com/systemjs/systemjs/issues/168)
207+
if (isBrowser)
208+
outPath = outPath.replace(/#/g, '%40');
211209

212210
return toAbsoluteURL(this.baseURL, outPath);
213211
},

test/test.js

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

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

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');
147+
test('Locate', System.locate({ name: '@abc/def' }), 'http://example.org/a/@abc/def.js');
151148
test('Locate', System.locate({ name: 'abc/def' }), 'http://example.org/a/abc/def.js');
152149

153150
// paths

0 commit comments

Comments
 (0)