Skip to content

Commit be71ba6

Browse files
authored
Merge pull request #286 from tencentyun/feature_jojoliang_bc993b5f
兼容url校验带path
2 parents 1aa1a55 + b0d535d commit be71ba6

File tree

2 files changed

+8
-7
lines changed

2 files changed

+8
-7
lines changed

cos.go

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ import (
2626

2727
const (
2828
// Version current go sdk version
29-
Version = "0.7.57"
29+
Version = "0.7.58"
3030
UserAgent = "cos-go-sdk-v5/" + Version
3131
contentTypeXML = "application/xml"
3232
defaultServiceBaseURL = "http://service.cos.myqcloud.com"
@@ -86,9 +86,6 @@ func (*BaseURL) innerCheck(u *url.URL, reg *regexp.Regexp) bool {
8686
if !strings.HasPrefix(urlStr, "https://") && !strings.HasPrefix(urlStr, "http://") {
8787
return false
8888
}
89-
if strings.Count(urlStr, "/") > 2 {
90-
return false
91-
}
9289
if domainSuffix.MatchString(urlStr) && !reg.MatchString(urlStr) {
9390
return false
9491
}
@@ -232,6 +229,10 @@ func NewClient(uri *BaseURL, httpClient *http.Client) *Client {
232229
return c
233230
}
234231

232+
func (c *Client) DisableURLCheck() {
233+
c.invalidURL = false
234+
}
235+
235236
type Credential struct {
236237
SecretID string
237238
SecretKey string
@@ -347,7 +348,7 @@ func (c *Client) doAPI(ctx context.Context, req *http.Request, result interface{
347348
ctx, cancel = context.WithCancel(ctx)
348349
defer cancel()
349350
}
350-
//req = req.WithContext(ctx)
351+
req = req.WithContext(ctx)
351352

352353
resp, err := c.client.Do(req)
353354
if err != nil {

cos_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -291,7 +291,7 @@ func Test_BaseURL(t *testing.T) {
291291
if (&BaseURL{BucketURL: u, ServiceURL: u, BatchURL: u}).Check() {
292292
t.Errorf("BaseURL check failed: %v", u)
293293
}
294-
u, _ = url.Parse("https://[email protected]/myqcloud.com")
294+
u, _ = url.Parse("https://[email protected]/.myqcloud.com")
295295
if (&BaseURL{BucketURL: u, ServiceURL: u, BatchURL: u}).Check() {
296296
t.Errorf("BaseURL check failed: %v", u)
297297
}
@@ -349,7 +349,7 @@ func Test_BaseURL(t *testing.T) {
349349
if (&BaseURL{BatchURL: u}).Check() {
350350
t.Errorf("BaseURL check failed: %v", u)
351351
}
352-
u, _ = url.Parse("http://cos-control.ap-guangzhou.myqcloud.com/www.com")
352+
u, _ = url.Parse("http://cos-control.ap-guangzhou.myqcloud.com")
353353
if (&BaseURL{BatchURL: u}).Check() {
354354
t.Errorf("BaseURL check failed: %v", u)
355355
}

0 commit comments

Comments
 (0)