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

False negative cases with new support for invalid IPV6 URLs #140

Closed
nkahnfr opened this issue Feb 1, 2022 · 2 comments
Closed

False negative cases with new support for invalid IPV6 URLs #140

nkahnfr opened this issue Feb 1, 2022 · 2 comments
Labels

Comments

@nkahnfr
Copy link

nkahnfr commented Feb 1, 2022

Hello.

First of all, thank you for that package and your work.

The commit that adds support for invalid IPV6 URLs (b32d16c) seems to introduce a parsing error for URLs with special query parameters like an ISO date and time (the colon is misinterpreted as an IPV6 address separator).
Here is an example of such an URL: http://www.sample.com/search?updated-max=2020-04-16T09:14:00+10:00

With current invalidIpv6Pattern the whole url is surrounded by []: http://[www.sample.com/search?updated-max=2020-04-16T09:14:00+10:00].

I think this behavior can be fixed by using the following updated pattern.
const invalidIpv6Pattern = /^([a-z][*+.a-z-]+:\/\/)([^[][^/?]*:[^/?]*:[^/?]*)(.*)/i;
This ensures that only the part before the first / or ? is taken into account to detect a potential IPV6 address (I replaced the .* pattern with [^/?]*).

Let me know if these comments are not clear enough.

@jhnns jhnns closed this as completed in 09071e6 Jun 30, 2022
github-actions bot pushed a commit that referenced this issue Jun 30, 2022
## [7.0.1](v7.0.0...v7.0.1) (2022-06-30)

### Bug Fixes

* Parse error with : when using fromUrl() ([09071e6](09071e6)), closes [#140](#140)
@github-actions
Copy link

🎉 This issue has been resolved in version 7.0.1 🎉

The release is available on:

Your semantic-release bot 📦🚀

@jhnns
Copy link
Member

jhnns commented Jun 30, 2022

Thanks for this detailed bug report ❤️

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

No branches or pull requests

2 participants