Skip to content

Commit

Permalink
Merge pull request #16 from ramir-savvy/etld1_private
Browse files Browse the repository at this point in the history
Hack etld1 for non icann public suffixes - thanks @ramir-savvy
  • Loading branch information
jpillora authored Jul 20, 2022
2 parents 78af86f + 6db9a89 commit 5bb907e
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
7 changes: 6 additions & 1 deletion parse.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,12 @@ func Parse(s string) (*URL, error) {
dom, port := domainPort(url.Host)
//etld+1
etld1, err := publicsuffix.EffectiveTLDPlusOne(dom)
_, icann := publicsuffix.PublicSuffix(strings.ToLower(dom))
suffix, icann := publicsuffix.PublicSuffix(strings.ToLower(dom))
// HACK: attempt to support valid domains which are not registered with ICAN
if err != nil && !icann && suffix == dom {
etld1 = dom
err = nil
}
if err != nil {
return nil, err
}
Expand Down
4 changes: 4 additions & 0 deletions parse_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,3 +46,7 @@ func Test5(t *testing.T) {
func Test6(t *testing.T) {
run("https://google.Com", "", "google", "Com", true, t)
}

func Test7(t *testing.T) {
run("https://github.io", "", "github", "io", false, t)
}

0 comments on commit 5bb907e

Please sign in to comment.