Closed StanislavPrusac closed 8 years ago
Looks like .cn
exists in publicsuffix.org -- and I don't think that the behavior you described is expected. So yeah -- I think it's a bug.
The bug occurs with any domain name that matches the start of a TLD.
For example with www.comscore.com
, domainname-parser thinks the TLD is comscore.com
, because it looks for the first index of .com
in the string.
It looks like the fix would be to update line 145 of DomainName.cs to use LastIndexOf
instead of IndexOf
?
Yep. I think changing this code would probably be the right approach. We should probably add this edge case to the unit tests.
@alexwarren :star: Great catch!
Wow -- it's been a while since I looked at those unit tests, too. They should be refactored to use Arrange / Act / Assert.
If you have "russian.cntv.cn" for parsing in line: tldIndex = domainString.IndexOf("." + MatchingRule.Name, StringComparison.InvariantCultureIgnoreCase);
https://github.com/danesparza/domainname-parser/blob/master/DomainName.Library/DomainName.cs#L145
you will get: tempSudomainAndDomain = "russian" TLD = "cntv.cn"
Is this error?