Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[0.20.4] URL missing single character with extra slash #1557

Closed
pe8ter opened this issue Jan 31, 2017 · 4 comments
Closed

[0.20.4] URL missing single character with extra slash #1557

pe8ter opened this issue Jan 31, 2017 · 4 comments

Comments

@pe8ter
Copy link

pe8ter commented Jan 31, 2017

Overview

Trying to load a simple script with a default .js extension but the URL is missing a character and has an extra slash. This did not happen in 0.20.3, but broke in 0.20.4. Here is my config:

SystemJS.config({
    packages: {
        '/': {
            defaultExtension: 'js',
        },
    },
});

And for completeness my import:

SystemJS.import('foo');

Expected result

The script foo.js should load and execute.

Actual result

The script fails to load with 400 (Bad Request):

GET http://localhost:3000//oo.js 400 (Bad Request)
N @ fetch.js:32
(anonymous) @ instantiate.js:165
Uncaught (in promise) Error: Fetch error: 400 Bad Request
  Instantiating http://localhost:3000//oo.js
  Loading /foo.js
    at fetch.js:37
t @ common.js:83
(anonymous) @ loader-polyfill.js:70

Apologies for the noisy error dump, but you can at least see the mangled URL.

@pe8ter
Copy link
Author

pe8ter commented Jan 31, 2017

I found the change between 0.20.3 and 0.20.4 that is the root of the issue. In config.js there is a line to create a variable pkgName. You can see here that the variable gets assigned then used. In the previous version there was one more line to cut off the trailing slash.

Now that the package name keeps the trailing slash when we get to finding the sub-path from the normalized URL, packageKey is too long so one extra character from the sub-path gets removed. The sub-path for http://localhost:3000/foo becomes oo instead of foo and thus the errors above.

@guybedford
Copy link
Member

@pe8ter thanks I've added this fix as you suggest in 647ccef.

@guybedford
Copy link
Member

Released in 0.20.5

@pe8ter
Copy link
Author

pe8ter commented Feb 1, 2017

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants