-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
37e7cc0
commit 57fd787
Showing
2 changed files
with
9 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,14 +10,15 @@ import ( | |
func main() { | ||
var fontStyle = []color.Attribute{color.FgHiWhite, color.Bold} | ||
|
||
// Hostname | ||
url := "https://[email protected]:5000/a/b?id=42" | ||
|
||
extractor, err := fasttld.New(fasttld.SuffixListParams{}) | ||
if err != nil { | ||
log.Fatal(err) | ||
} | ||
res, _ := extractor.Extract(fasttld.URLParams{URL: url}) | ||
color.New(fontStyle...).Println("Domain") | ||
color.New(fontStyle...).Println("Hostname") | ||
fasttld.PrintRes(url, res) | ||
|
||
// Specify custom public suffix list file | ||
|
@@ -87,8 +88,9 @@ func main() { | |
|
||
color.New(fontStyle...).Println("Parsing errors") | ||
color.New().Println("The following line should be an error message") | ||
if _, err := extractor.Extract(fasttld.URLParams{URL: url}); err != nil { | ||
if res, err = extractor.Extract(fasttld.URLParams{URL: url}); err != nil { | ||
color.New(color.FgHiRed, color.Bold).Print("Error: ") | ||
color.New(color.FgHiWhite).Println(err) | ||
} | ||
fasttld.PrintRes(url, res) // Partially extracted subcomponents can still be retrieved | ||
} |