Skip to content
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

apexDomain returns None for IDNs and FQDNs #509

Open
ruurtjan opened this issue May 10, 2023 · 1 comment
Open

apexDomain returns None for IDNs and FQDNs #509

ruurtjan opened this issue May 10, 2023 · 1 comment
Assignees

Comments

@ruurtjan
Copy link

Describe the bug
The DomainName#apexDomain function returns None for two types of domain names that are valid, and have a suffix listed in PublicSuffixes.scala:

  1. punycode IDNs
  2. Fully qualified domain names (domain names with a trailing dot)

Reference:

To Reproduce

object ApexBugs extends App {

  // This works fine:

  println(DomainName.parseOption("www.example.移动"))
  // Some("www.example.移动")
  
  println(DomainName.parseOption("www.example.移动").get.apexDomain)
  // Some("example.移动")


  // This fails:

  println(DomainName.parseOption("www.example.xn--6frz82g"))
  // Some("www.example.xn--6frz82g")

  println(DomainName.parseOption("www.example.xn--6frz82g").get.apexDomain)
  // None

  println(DomainName.parseOption("www.example.com."))
  // Some("www.example.com.")

  println(DomainName.parseOption("www.example.com.").get.apexDomain)
  // None

}
@ruurtjan
Copy link
Author

The workaround for this — if anyone comes across this as well — is to check and strip the dot at the end, and convert the domain name to unicode before calling .apexDomain.

java.net.IDN.toUnicode("www.example.xn--6frz82g")

fedorovar added a commit to ActianCorp/scala-uri that referenced this issue Apr 22, 2024
FLimburg pushed a commit to ActianCorp/scala-uri that referenced this issue Apr 23, 2024
* fixes issue lemonlabsuk#509 from original repo

* formated files
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants