TLDExtractSwift icon indicating copy to clipboard operation
TLDExtractSwift copied to clipboard

Example with idna-encoded string does not work

Open TAKeanice opened this issue 4 years ago • 0 comments

Thanks for this library. I am using it as SPM dependency and recognized the following bug:

The PunycodeSwift library returns "http://www.ラーメン.寿司.co.jp".idnaEncoded! as xn--http://www-.xn--4dkp5a8a.xn--sprr0q.co.jp and "https://test.com".idnaEncoded! as xn--https://test-.com

I am posting this here, because clearly the PunycodeSwift is just doing its job here, but TLDExtractSwift has this as example in its readme.

Possible solutions:

  • remove example
  • provide a way to apply idna encoding only to parts that are not the protocol or other parts of URLs that should not be encoded. For that, TLDExtractSwift only needs one extra method calling into PunycodeSwift, transforming the individual url components.
  • save the protocol definition at the beginning of the url string, so the user can apply Punycode to the individual parts and then re-assemble the URL himself

TAKeanice avatar Nov 01 '20 16:11 TAKeanice