Skip to content

Conversation

federico-po
Copy link

@federico-po federico-po commented Jul 7, 2025

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)

@federico-po federico-po self-assigned this Jul 7, 2025
@@ -96,7 +96,30 @@ function url(strings, ...args) {

return encodeComponent(raw)
})
const res = [strings[0], ...escaped.flatMap((arg, i) => [arg, strings[i + 1]])].join('')

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()

Copy link
Author

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('')
}

Copy link
Contributor

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

Copy link
Author

@federico-po federico-po Jul 7, 2025

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)

Copy link
Contributor

@ChALkeR ChALkeR Jul 7, 2025

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}

Copy link
Author

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

Copy link
Contributor

@ChALkeR ChALkeR left a 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

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

Successfully merging this pull request may close these issues.

3 participants