mirror of
https://github.com/duke-git/lancet.git
synced 2025-09-26 19:41:20 +08:00
fix: fix issue #314
This commit is contained in:
@@ -365,7 +365,7 @@ func validateScheme(scheme string) error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
var hostRegex = regexp.MustCompile(`^([a-zA-Z0-9]|[a-zA-Z0-9][a-zA-Z0-9\-]*[a-zA-Z0-9])(\.[a-zA-Z0-9]|[a-zA-Z0-9][a-zA-Z0-9\-]*[a-zA-Z0-9])*$`)
|
var hostRegex = regexp.MustCompile(`^([a-zA-Z0-9][a-zA-Z0-9\-]*[a-zA-Z0-9]?)(\.[a-zA-Z0-9][a-zA-Z0-9\-]*[a-zA-Z0-9]?)+$`)
|
||||||
var pathRegex = regexp.MustCompile(`^\/([a-zA-Z0-9%_-]+(?:\/[a-zA-Z0-9%_-]+)*)$`)
|
var pathRegex = regexp.MustCompile(`^\/([a-zA-Z0-9%_-]+(?:\/[a-zA-Z0-9%_-]+)*)$`)
|
||||||
|
|
||||||
var alphaNumericRegex = regexp.MustCompile(`^[a-zA-Z0-9]+$`)
|
var alphaNumericRegex = regexp.MustCompile(`^[a-zA-Z0-9]+$`)
|
||||||
|
@@ -196,6 +196,14 @@ func TestBuildUrl(t *testing.T) {
|
|||||||
want: "https://www.test.com/path%20with%20spaces",
|
want: "https://www.test.com/path%20with%20spaces",
|
||||||
wantErr: false,
|
wantErr: false,
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
scheme: "https",
|
||||||
|
host: "my.api.edu.cn",
|
||||||
|
path: "/api",
|
||||||
|
query: nil,
|
||||||
|
want: "https://my.api.edu.cn/api",
|
||||||
|
wantErr: false,
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, tt := range tests {
|
for _, tt := range tests {
|
||||||
|
Reference in New Issue
Block a user