Open mathiasbynens opened 10 years ago
As per @annevk’s http://annevankesteren.nl/2014/06/url-unicode, http://unicode.org/reports/tr46/ should be used. It’s compatible with IDNA2003, but uses IDNA2008 data.
potentially related work: reference implementation, live demo, updated parser spec
For what it's worth, I started coding up a UTR#46 implementation in JS. You don't need stringprep/nameprep (you can use http://www.unicode.org/Public/idna/7.0.0/IdnaMappingTable.txt instead, and without detailed Unicode property reflection in JS, you'll have to have a table lookup anyways). Unfortunately, the UTR46 test vectors drove me insane because they don't match the propose as near as I can tell. I did not try to implement the contextual rules, and I gave up on trying to get the bidi rules to match. Since those rules are mostly about what labels are valid and don't otherwise change the mapping, I feel it's okay to ignore them for most JS library purposes.
FWIW, I just uploaded some code I have to https://github.com/jcranmer/idna-uts46, which implements much of UTS #46 (sans Bidi and contextual because screw them).
All of the browsers already implement IDN handling, are you sure we shouldn't advocate for exposing this functionality in ES7? I've never actually pushed for a standard before, but the browser vendors really need to be in lockstep with IDN handling anyway....
https://url.spec.whatwg.org/#api has some API surface for this, but it's not implemented (yet).
@annevk Tickets at Kangax and caniuse might increase visibility.
Go for it. I don't really want to do that having designed the API. Seems better if others advocate for it.
String.prototype.normalize
polyfill (or useunorm
?)IDNA2003Unicode TR46 as per the URL standardReferences