Get the second level domain of an URL (java)

前端 未结 10 900
长发绾君心
长发绾君心 2020-12-06 01:04

I am wondering if there is a parser or library in java for extracting the second level domain (SLD) in an URL - or failing that an algo or regex for doing the same. For exam

10条回答
  •  庸人自扰
    2020-12-06 01:18

    After reeading everything here, the correct solution should be (with guava)

    InternetDomainName.from(uriHost).topPrivateDomain().toString();

    errors when using Guava to get the private domain name

提交回复
热议问题