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

[Editorial] Simplify the ends-in-a-number checker #633

Merged
merged 3 commits into from
Oct 21, 2021

Conversation

karwa
Copy link
Contributor

@karwa karwa commented Aug 24, 2021

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

@karwa
Copy link
Contributor Author

karwa commented Aug 30, 2021

@annevk Do you think this is reasonable?

@achristensen07
Copy link
Collaborator

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.

@annevk
Copy link
Member

annevk commented Aug 31, 2021

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).

url.bs Show resolved Hide resolved
url.bs Outdated Show resolved Hide resolved
@annevk
Copy link
Member

annevk commented Oct 19, 2021

Now that I created #661 I feel more comfortable landing this. I'll address the nits.

@annevk
Copy link
Member

annevk commented Oct 19, 2021

Looking at this again this basically means deferring when "09" is handled. This seems okay, but I'd like @domenic or @TimothyGu to weigh in.

Copy link
Member

@domenic domenic left a 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.

url.bs Outdated Show resolved Hide resolved
@annevk annevk merged commit 9a0087e into whatwg:main Oct 21, 2021
@annevk
Copy link
Member

annevk commented Oct 21, 2021

Looking at this again this basically means deferring when "09" is handled.

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.

@karwa karwa deleted the thats-numberwang branch October 25, 2021 12:52
@karwa
Copy link
Contributor Author

karwa commented Oct 25, 2021

Thanks very much for landing this @annevk!

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

Successfully merging this pull request may close these issues.

4 participants