Skip to content

fix: remove doubled slash when using URL instance#35

Closed
federico-po wants to merge 2 commits into
masterfrom
fede/fix-double-slash
Closed

fix: remove doubled slash when using URL instance#35
federico-po wants to merge 2 commits into
masterfrom
fede/fix-double-slash

Conversation

@federico-po

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

Copy link
Copy Markdown

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
Comment thread url.js
return encodeComponent(raw)
})
const res = [strings[0], ...escaped.flatMap((arg, i) => [arg, strings[i + 1]])].join('')

Copy link
Copy Markdown

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
Copy Markdown
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

Comment thread url.js
} else {
res = [strings[0], ...escaped.flatMap((arg, i) => [arg, strings[i + 1]])].join('')
}

Copy link
Copy Markdown
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

@federico-po federico-po Jul 7, 2025

Copy link
Copy Markdown
Author

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)

@ChALkeR ChALkeR Jul 7, 2025

Copy link
Copy Markdown
Contributor

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
Copy Markdown
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

Comment thread url.js

@ChALkeR ChALkeR left a comment

Copy link
Copy Markdown
Contributor

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

@federico-po federico-po deleted the fede/fix-double-slash branch October 17, 2025 12:27
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