-
Notifications
You must be signed in to change notification settings - Fork 160
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
toASCII
returns incorrect result
#66
Comments
What makes you say that’s the expected output, and that the current output is “invalid Punycode”? Could you elaborate please? Update: Entering e.g. |
Yes, sorry. I've been converting many emojis and because the punycode isn't correct many of them haven't been appearing correctly, which is what pushed me to investigate further. I tested on many conversion sites to test that out. The main one I trust most is Punycoder. If you try converting those strings above, you will find the results I was describing. |
toASCII
returns incorrect result
|
Cluster-Nobes has given a networking drive & wifi-drive. Having first error on Nobe-3 |
This is not really a bug. It's a limitation.
The second character is U+FE0F. If you drop it from the input, you get the correct result. Take a look at idna-uts46 for a more detailed explanation. Here's a quick alternative that works in the browser as well as Node.js: let toASCII = d => d.split('.').map(l => new URL(`ws://${l}`).hostname).join('.'); |
While converting various emojis, I've found that very often it is not converting them correctly.
What I'd expect:
1.
punycode.toASCII( "❄️🙊" )
should equal "xn--tdix719m" where instead it equals "xn--tdiy444e5vxg" (invalid punycode)2.
punycode.toASCII( "👰✉️" )
should equal "xn--4bi6168m" where instead it equals "xn--4biw254ehqwg" (invalid punycode)I could give many more examples, but I haven't found a pattern in the mistake.
The text was updated successfully, but these errors were encountered: