Skip to content

Commit 65227cb

Browse files
committed
fix(cdn) JoinStringMap: define order
1 parent 1a0feaa commit 65227cb

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

internal/pkg/utils/strings.go

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package utils
22

33
import (
44
"fmt"
5+
"slices"
56
"strings"
67
"unicode/utf8"
78
)
@@ -32,9 +33,14 @@ func JoinStringMap(m map[string]string, keyValueSeparator, separator string) str
3233
if m == nil {
3334
return ""
3435
}
36+
keys := make([]string, 0, len(m))
37+
for k := range m {
38+
keys = append(keys, k)
39+
}
40+
slices.Sort(keys)
3541
parts := make([]string, 0, len(m))
36-
for k, v := range m {
37-
parts = append(parts, fmt.Sprintf("%s%s%s", k, keyValueSeparator, v))
42+
for _, k := range keys {
43+
parts = append(parts, fmt.Sprintf("%s%s%s", k, keyValueSeparator, m[k]))
3844
}
3945
return strings.Join(parts, separator)
4046
}

0 commit comments

Comments
 (0)