-
Notifications
You must be signed in to change notification settings - Fork 0
fix: remove doubled slash when using URL instance #35
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
base: master
Are you sure you want to change the base?
Conversation
@@ -96,7 +96,30 @@ function url(strings, ...args) { | |||
|
|||
return encodeComponent(raw) | |||
}) | |||
const res = [strings[0], ...escaped.flatMap((arg, i) => [arg, strings[i + 1]])].join('') | |||
|
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.
Perhaps this has already been discussed: why not use the native URL
object? It should account for //
in the path.
new URL('/path', 'https://exodus.com/').toString()
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 can't remember why we added url
, maybe @sparten11740 or @ChALkeR knows better
} else { | ||
res = [strings[0], ...escaped.flatMap((arg, i) => [arg, strings[i + 1]])].join('') | ||
} | ||
|
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.
the impl looks too complex
will review separately, don't land without a review
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 echo's Gonzalo's question above: why do we need to use url
? couldn't we just use URL? can't remember when it was asked to use (probably in a PR review)
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.
couldn't we just use URL
You can use URL. new URL('/foo/bar', 'https://example.com')
is perfectly fine.
Just don't do something like https://example.com/${unescaped arg}
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'll update the clients to change it. Although, we should still land this fix or remove url
in favor of standard URL
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.
this doesn't take into account the location
only paths portions should be trimmed
The test I added fails in master since the url is
https://example.org//foo
.The doubled
//
ad the end makes fetch fails.(note: I used AI to fix the issue, so please evaluate if anything else is needed)