-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
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
Remove node-isms from SvelteKit runtime #1117
Conversation
This pull request is being automatically deployed with Vercel (learn more). 🔍 Inspect: https://vercel.com/sveltejs/kit-demo/Dw1rZHzXYrZQ3dUCgFbVQKHK9k5o |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm worried about this logic if someone does a same-protocol request. new URL('//foo/bar', 'sveltekit://origin')
resolves to 'sveltekit://foo/bar'
but shouldn't be treated as an internal fetch.
Perhaps use an unusual domain as well in the base, and also check for that when deciding whether this is an internal fetch?
Actually it turns out Though I'm not really sure what the correct behaviour would be in the case of a protocol-relative request. Can we even ascertain the protocol that it's relative to? Maybe any path that |
Huh.
But yeah, now that you mention it, I'm not sure what a protocol-relative request should do in SSR, since there's no certain way to know what that protocol is. Making it explicitly an error seems to be the only sensible thing. |
It works in Node but fails in the browser. Which is probably fine but if Node ever decides they want to match browser behaviour more closely, it would be a headache. Also, Deno etc might be stricter. Will change it, out of paranoia |
Jesus, Node's new URL('./bar', 'sveltekit://origin/baz/qux').pathname equates to Screw this, I'm going to find a URL parsing library |
Isn't If I do |
The browser is 'correct' by virtue of being the browser; Node's job is to match its behaviour. I'd be very surprised if browsers aren't behaving according to spec here, even if the spec has surprising outcomes |
If you're concerned about the browser's behavior being technically correct and about Node's behavior one day switching to match it, I'd then still strongly recommend using a URL with a known protocol that browsers and Node will handle the same way, rather than bringing in a URL parsing library. |
is this still 'changes requested' @Conduitry or are you 👍 on this? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, sorry, nope, I'm 👍 now.
This will make it marginally easier to use in environments that don't resemble Node, like Cloudflare Workers and Deno
Before submitting the PR, please make sure you do the following
Tests
pnpm test
and lint the project withpnpm lint
Changesets
pnpx changeset
and following the prompts