Skip to content
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

fix: normalizeURL does not ensure path name starts with a / #177

Closed
dargmuesli opened this issue Sep 11, 2023 · 4 comments
Closed

fix: normalizeURL does not ensure path name starts with a / #177

dargmuesli opened this issue Sep 11, 2023 · 4 comments

Comments

@dargmuesli
Copy link

Environment



Reproduction

https://stackblitz.com/edit/stackblitz-starters-rbpv5q?file=index.mjs

Describe the bug

The example in the README does not work as specified.

Additional context

No response

Logs

No response

dargmuesli added a commit to dargmuesli/vio that referenced this issue Sep 11, 2023
dargmuesli added a commit to dargmuesli/vio that referenced this issue Sep 12, 2023
@pi0
Copy link
Member

pi0 commented Sep 12, 2023

Hi. Can you please share the context of this issue and did you find any standards that specify a valid URL needs one trailing slash at least? (because browser URL, doesn'y do it, but URL constructor seems to add. i didn't check any standards yet)

@dargmuesli
Copy link
Author

I just expected to happen what's written in the README of this project. I'm not sure about standards and thus am fine with changing the README too to reflect the actual behavior of ufo.

@Anoesj
Copy link

Anoesj commented Jan 3, 2024

I agree the README should be updated, because normalizeURL does not ensure a leading slash if pathname is ''.

Had to add this in my own project:

const normalizedURL = normalizeURL(url);
const { host, pathname, search } = parseURL(normalizedURL);
const pathnameCleaned = pathname === '' ? '/' : pathname;

pi0 added a commit that referenced this issue Feb 5, 2024
@pi0
Copy link
Member

pi0 commented Feb 5, 2024

Docs updated in the meantime and for v2 it is likely this behavior changes (~>#208).

If v1 was not widely used, I would add it as a fix but this fix has potential of breaking some other cases.

(closing to track from one place for all side-effects in v2)

@pi0 pi0 closed this as completed Feb 5, 2024
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

No branches or pull requests

3 participants