Skip to content

Commit c6ef7e6

Browse files
authored
Merge pull request #144 from gofiber/add-cbor-in-mimeExtension-list
2 parents 9a4ecdd + 907fef6 commit c6ef7e6

File tree

5 files changed

+9
-8
lines changed

5 files changed

+9
-8
lines changed

bytes.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,15 @@ package utils
66

77
// ToLowerBytes converts ascii slice to lower-case
88
func ToLowerBytes(b []byte) []byte {
9-
for i := 0; i < len(b); i++ {
9+
for i := range b {
1010
b[i] = toLowerTable[b[i]]
1111
}
1212
return b
1313
}
1414

1515
// ToUpperBytes converts ascii slice to upper-case
1616
func ToUpperBytes(b []byte) []byte {
17-
for i := 0; i < len(b); i++ {
17+
for i := range b {
1818
b[i] = toUpperTable[b[i]]
1919
}
2020
return b

common.go

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import (
1313
"os"
1414
"reflect"
1515
"runtime"
16+
"slices"
1617
"strconv"
1718
"strings"
1819
"sync"
@@ -105,12 +106,7 @@ func FunctionName(fn any) string {
105106

106107
// GetArgument check if key is in arguments
107108
func GetArgument(arg string) bool {
108-
for i := range os.Args[1:] {
109-
if os.Args[1:][i] == arg {
110-
return true
111-
}
112-
}
113-
return false
109+
return slices.Contains(os.Args[1:], arg)
114110
}
115111

116112
// IncrementIPRange Find available next IP address

http.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,7 @@ var mimeExtensions = map[string]string{
168168
"shtml": "text/html",
169169
"css": "text/css",
170170
"xml": "application/xml",
171+
"cbor": "application/cbor",
171172
"gif": "image/gif",
172173
"jpeg": "image/jpeg",
173174
"jpg": "image/jpeg",

http_test.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,9 @@ func Test_GetMIME(t *testing.T) {
3232
res = GetMIME("zst")
3333
require.Equal(t, "application/zstd", res)
3434

35+
res = GetMIME("cbor")
36+
require.Equal(t, "application/cbor", res)
37+
3538
// empty case
3639
res = GetMIME("")
3740
require.Equal(t, "", res)

ips.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import (
77
// IsIPv4 works the same way as net.ParseIP,
88
// but without check for IPv6 case and without returning net.IP slice, whereby IsIPv4 makes no allocations.
99
func IsIPv4(s string) bool {
10+
//nolint:modernize-loop // old way is more readable
1011
for i := 0; i < net.IPv4len; i++ {
1112
if len(s) == 0 {
1213
return false

0 commit comments

Comments
 (0)