-
Notifications
You must be signed in to change notification settings - Fork 140
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
[Editorial] Simplify the ends-in-a-number checker #633
Conversation
@annevk Do you think this is reasonable? |
FWIW, this is how I implemented it. Calling the IPv4 parser is too slow. I just checked for all digits and 0x or 0X and hex digits. |
Yeah this seems fine, modulo some formatting nits. I would like some way to preserve the 09 example, but perhaps the way to do that is to have an example table for hosts similar to what we have for URLs at https://url.spec.whatwg.org/#urls, at https://url.spec.whatwg.org/#hosts-(domains-and-ip-addresses). |
Now that I created #661 I feel more comfortable landing this. I'll address the nits. |
Looking at this again this basically means deferring when " |
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.
Tested in whatwg-url and works, modulo the ambiguity with the note.
FWIW, I realized this is wrong as the former text does the same as the new text (the first step would get failure and then the second step would return true). Fortunately the new notes are correct despite this misunderstanding with regards to the implications. |
Thanks very much for landing this @annevk! |
I believe this should be functionally identical to what exists already.
IMO it's more intuitive, because it means the "ends in a number" checker first checks to see if the label is all digits (which obviously means it is a number), and then checks to see if it's a number containing non-digit characters (i.e. just hex numbers). I think it's clearer and more obvious than the current wording, which first invokes the more expensive IPv4 number parser and then adds a second check because of particular failure conditions.
Writing it this way in the spec gives implementors assurance that this is a safe optimisation.
Preview | Diff