Closed Insolita closed 5 years ago
@Insolita from reading your issue I have to wonder if adding a format method to the Domain VO which accepts IDNA_* constant would not be the correct way to solve it 🤔
@nyamsprod Is will be not enough to add it only into Domain VO. It should be accepted also in each class that can create Domain instance or idnToAscii/idnToUnicode methods from IDNAConverterTrait
I was thinking about the DomainInterface 😉 so yes it will be implemented on the PublicSuffix VO as well. If you can provide a PR for it I'll gladly review it 🎉
Issue summary
The trouble happens when i try convert domains with some specific characters called "deviations" in my case is ß (more information in http://unicode.org/reports/tr46/#Transition_Considerations)
System informations
Standalone code, or other way to reproduce the problem
Expected result
In my case i expect to get "faß.de" as unicode and xn--fa-hia.de as ascii This happens because function idn_to_utf8 https://github.com/jeremykendall/php-domain-parser/blob/develop/src/IDNAConverterTrait.php#L149 and idn_to_acii https://github.com/jeremykendall/php-domain-parser/blob/develop/src/IDNAConverterTrait.php#L118 used with option = 0;
But for expected result option IDNA_NONTRANSITIONAL_TO_UNICODE (32) required for idn_to_utf8 and IDNA_NONTRANSITIONAL_TO_ASCII for idn_to_acii https://www.php.net/manual/en/intl.constants.php
So i want to have ability to set my custom option for idn convertation. I can make PR if we agree on how to pass this option. Or it can be used as default; with IDNA_DEFAULT option - idn_to_ascii for fass.de and faß.de - are same and it can provide some unexpected behavior Also it will be good to have method for checking is domainName contains deviation characters