Skip to content

Commit 70f21d5

Browse files
committed
fix cors domain normalize
1 parent f9fcb02 commit 70f21d5

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

middleware/cors/utils.go

+4-2
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,10 @@ func normalizeDomain(input string) string {
4949
input = strings.TrimPrefix(strings.TrimPrefix(input, "http://"), "https://")
5050

5151
// Find and remove port, if present
52-
if portIndex := strings.Index(input, ":"); portIndex != -1 {
53-
input = input[:portIndex]
52+
if len(input) > 0 && input[0] != '[' {
53+
if portIndex := strings.Index(input, ":"); portIndex != -1 {
54+
input = input[:portIndex]
55+
}
5456
}
5557

5658
return input

0 commit comments

Comments
 (0)