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

Too strict url check #120

Closed
danielepolencic opened this issue Aug 18, 2020 · 2 comments
Closed

Too strict url check #120

danielepolencic opened this issue Aug 18, 2020 · 2 comments
Labels
good first issue Good for newcomers

Comments

@danielepolencic
Copy link
Contributor

danielepolencic commented Aug 18, 2020

The following URL fails the validation:

http://nautil.us/issue/88/love--sex/the-hard-problem-of-breakfast

However, the same URL is accepted without any issue by the URL class:

> new URL('http://nautil.us//issue/88/love--sex/the-hard-problem-of-breakfast').toString()
'http://nautil.us//issue/88/love--sex/the-hard-problem-of-breakfast'

I'm not familiar with the intricacies of validating URLs, so this might be a non-issue. But I thought about reporting it since I can use the URL just fine.

Using zod 1.10.1

@colinhacks
Copy link
Owner

colinhacks commented Aug 18, 2020

The first URL is parsing fine for me. The URL you're passing into new URL is different from the first: it contains two slashes after nautil.us. Nautilus still manages to serve the correct page, but in general double slashes won't work as expected in URLs.

That said: I hadn't considered using new URL as a way of checking for valid URLs...I like the idea! I would accept a PR that switches URL validation over to that approach, since it feels more Javascript-native.

@colinhacks
Copy link
Owner

Merged your PR and published in [email protected]. Thanks Daniele!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

2 participants