jpillora / go-tld

TLD Parser in Go
MIT License
125 stars 18 forks source link

Document Link / Extension not Supported .PDF , .HTMLetc #4

Open JohnDotOwl opened 5 years ago

JohnDotOwl commented 5 years ago
package main

import (
    "fmt"

    "github.com/jpillora/go-tld"
)

func main() {
    urls := []string{
        "http://google.com",
        "http://blog.google",
        "https://www.medi-cal.ca.gov/",
        "https://ato.gov.au",
        "http://a.very.complex-domain.co.uk:8080/foo/bar",
        "https://s3.amazonaws.com/happiness-report/2019/WHR19.pdf",

    }
    for _, url := range urls {
        u, _ := tld.Parse(url)
        fmt.Printf("%50s = [ %s ] [ %s ] [ %s ] [ %s ] [ %s ]\n",
            u, u.Subdomain, u.Domain, u.TLD, u.Port, u.Path)
    }
}

panic: runtime error: index out of range

this lib is easy to use, i love it :)