Skip to content

Commit

Permalink
fix: fix bug of schema:host new feature
Browse files Browse the repository at this point in the history
  • Loading branch information
mstxq17 committed Sep 2, 2024
1 parent 7738ab9 commit f15e015
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 6 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ jobs:
# either 'goreleaser' (default) or 'goreleaser-pro'
distribution: goreleaser
version: latest
args: release --rm-dist
args: release --clean
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# Your GoReleaser Pro key, if you are using the 'gorel
14 changes: 10 additions & 4 deletions core/extract/simple_url.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,24 +3,30 @@ package extract
import (
"fmt"
"net/url"
"strings"
)

func SimpleUrl(input string) (string, bool, error) {
var hasSchema bool
if strings.Contains(input, "://") {
hasSchema = true
} else {
hasSchema = false
input = fmt.Sprintf("http://%s", input)
}
parsed, err := url.Parse(input)
if err != nil {
return "", false, err
}
if parsed.Scheme != "" {
if hasSchema == true {
tSimpleUrl := fmt.Sprintf("%s://%s", parsed.Scheme, parsed.Host)
return tSimpleUrl, true, nil
} else {
// 拼接协议进行解析
modifiedHost := fmt.Sprintf("http://%s", input)
parsed, err := url.Parse(modifiedHost)
if err != nil {
return "", false, err
} else {
tSimpleUrl := fmt.Sprintf("%s", parsed.Hostname())
tSimpleUrl := fmt.Sprintf("%s", parsed.Host)
return tSimpleUrl, false, nil
}
}
Expand Down
2 changes: 1 addition & 1 deletion gr_test.sh
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
#!/usr/bin/env bash
goreleaser --skip-publish --snapshot --rm-dist
goreleaser --skip "publish" --snapshot --clean

0 comments on commit f15e015

Please sign in to comment.