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

Sveltekit crashes with a double slash path #6747

Closed
infusion opened this issue Sep 12, 2022 · 2 comments
Closed

Sveltekit crashes with a double slash path #6747

infusion opened this issue Sep 12, 2022 · 2 comments

Comments

@infusion
Copy link

Describe the bug

Hello,

we had a strange problem occurring in production where svelte-kit crashes when calling the site with https://foo.com//. The problem is, that the JavaScript URL class can't handle a single double slash string, such es

new URL('//', 'http://dummy')

Probably this syntax expects a string after the slashes, as it is the start of a schemaless URL, such as //foo.com/bla.

Surprisingly the crash does not occur on my local Macbook with the project being run using npm run dev. Here a redirect happens, which is also the expected behavior.

Thanks

Reproduction

In the built version of the project, go to the site https://foo.com// with double slashes at the end.

Logs

node:internal/url:553
  throw new ERR_INVALID_URL(input);
  ^

TypeError [ERR_INVALID_URL]: Invalid URL
    at new NodeError (node:internal/errors:372:5)
    at URL.onParseError (node:internal/url:553:9)
    at new URL (node:internal/url:629:5)
    at file:///www/project/node_modules/@sveltejs/kit/dist/chunks/index5.js:101:33
    at next (file:///www/project/node_modules/@sveltejs/kit/dist/chunks/index5.js:218:5)
    at file:///www/project/node_modules/@sveltejs/kit/dist/chunks/index5.js:218:29
    at file:///www/project/node_modules/@sveltejs/kit/dist/chunks/index5.js:34:25
    at next (file:///www/project/node_modules/@sveltejs/kit/dist/chunks/index5.js:218:5)
    at file:///www/project/node_modules/@sveltejs/kit/dist/chunks/index5.js:218:29
    at file:///www/project/node_modules/@sveltejs/kit/dist/chunks/constants.js:642:28 {
  input: '//',
  code: 'ERR_INVALID_URL'
}

System Info

System:
    OS: Linux 4.15 Ubuntu 18.04.6 LTS (Bionic Beaver)
    CPU: (2) x64 Intel(R) Xeon(R) Gold 6140 CPU @ 2.30GHz
    Memory: 6.33 GB / 7.79 GB
    Container: Yes
    Shell: 5.4.2 - /usr/bin/zsh
  Binaries:
    Node: 16.15.1 - /usr/bin/node
    npm: 8.17.0 - /usr/local/bin/npm

Severity

serious, but I can work around it

Additional Information

No response

@Conduitry
Copy link
Member

This sounds like #2532, and should have been fixed some time ago. What version of SvelteKit are you on?

@infusion
Copy link
Author

Thanks, I searched for the problem on the issues but couldn't find #2532, thanks. Seems the built did not upgrade the kit, it still runs on 1.0.0-next.303.

@Conduitry Conduitry closed this as not planned Won't fix, can't repro, duplicate, stale Sep 12, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants