Skip to content

Don't fail with malformed URIs#81

Open
thewilkybarkid wants to merge 1 commit into
gcanti:masterfrom
thewilkybarkid:malformed-uris
Open

Don't fail with malformed URIs#81
thewilkybarkid wants to merge 1 commit into
gcanti:masterfrom
thewilkybarkid:malformed-uris

Conversation

@thewilkybarkid
Copy link
Copy Markdown

We've seen failures with URIs like // and /%F6, where new URL and decodeURIComponent throw, respectively. This change fixes those cases.

thewilkybarkid added a commit to thewilkybarkid/hyper-ts-routing that referenced this pull request May 1, 2025
Comment thread src/route.ts
*/
static parse(s: string, decode: boolean = true): Route {
const { pathname, searchParams } = new URL(s, 'http://localhost') // `base` is needed when `path` is relative
const { pathname, searchParams } = s.startsWith('/')
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@thewilkybarkid uhm, according to your description this change was added just for //: wouldn't have been better to handle that specific, edge case only?

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.

2 participants