-
Notifications
You must be signed in to change notification settings - Fork 56
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
Add ip validation #108
Add ip validation #108
Conversation
1ccc343
to
bd5b82d
Compare
If this seems reasonable to you, I will also need to update the README with the extra fields in |
It seems that |
@remusao maybe the URL parser could be configured as you did for the hostname extraction. This way the strictness cost is taken only by people who need id. |
@oncletom Yes why not! Although technically speaking, the url parsing is done inside of |
I will revert the change on the parser and only do the ip validation for this PR. Then we can change the parsing in another PR later since that does seem to require a bit more work than expected! |
@oncletom Done, but it seems that |
@oncletom Done, let me know what you think. |
test/tld.js
Outdated
it('should return true on valid ip addresses', function () { | ||
expect(tld.isIp('::1')).to.be(true); | ||
expect(tld.isIp('2001:0db8:85a3:0000:0000:8a2e:0370:7334')).to.be(true); | ||
expect(tld.isIp('192.168.0.1')).to.be(true); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would it make a difference if there is a port
in the IP address?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not really. isIp
will just check that some properties of the hostname
that usually indicates an ip address are met. The port
would be stripped during the parsing of the URL itself, before we check if the input is an ip
so that should not be an issue in practice.
@oncletom Is there any other change needed for this PR? |
@oncletom Sorry to bother, I updated the README + added a few comments. Let me know if you think it could be merged, or if it requires any change. |
This PR addresses #104. Changes:
hostname
is also an IP, and return consistent results.benchmark.js
to show performance when a valid hostname is directly given as input (no URL parsing necessary) vs. when a URL is given (parsing necessary).Here is a more detailed view of the current performance: