Skip to content

Commit

Permalink
修复 hostname 为空的情况
Browse files Browse the repository at this point in the history
  • Loading branch information
wjlin0 committed Jan 13, 2024
1 parent d4946a9 commit 1c8628e
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion sources/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,11 @@ func GetHostname(u string) (string, error) {
if err != nil {
return "", err
}
return parsedURL.Hostname(), nil
hostname := parsedURL.Hostname()
if hostname == "" {
return "", fmt.Errorf("invalid url")
}
return hostname, nil
}

var ifDomainReg = regexp.MustCompile("(?i)[a-z0-9][-a-z0-9]{0,62}(\\.[a-z0-9][-a-z0-9]{0,62})+$")
Expand Down

0 comments on commit 1c8628e

Please sign in to comment.