Skip to content

Commit

Permalink
gurl
Browse files Browse the repository at this point in the history
  • Loading branch information
snail007 committed Feb 7, 2025
1 parent 7fb5512 commit b6a238a
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
5 changes: 5 additions & 0 deletions util/url/url.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,11 @@ func (s *Builder) Query(data map[string]string) *Builder {
return s
}

func (s *Builder) SetQuery(k, v string) *Builder {
s.query[k] = v
return s
}

func (s *Builder) HostsURL(hosts []string) (urlArr []string) {
h0 := s.URL.Host
for _, h := range hosts {
Expand Down
2 changes: 2 additions & 0 deletions util/url/url_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ func TestURLBuilder_Query(t *testing.T) {
assert.Equal(t, "http://a.com:88/", link.String())
link = NewBuilder().Host("a.com").Port("88")
assert.Equal(t, "http://a.com:88/", link.String())
link = NewBuilder().Host("a.com").Port("88").SetQuery("a", "1")
assert.Equal(t, "http://a.com:88/?a=1", link.String())
}

func TestGetConcatChar(t *testing.T) {
Expand Down

0 comments on commit b6a238a

Please sign in to comment.