| 1 | // ⚡️ Fiber is an Express inspired web framework written in Go with ☕️ |
| 2 | // 🤖 Github Repository: https://github.com/gofiber/fiber |
| 3 | // 📌 API Documentation: https://docs.gofiber.io |
| 4 | |
| 5 | package utils |
| 6 | |
| 7 | import ( |
| 8 | casestrings "github.com/gofiber/utils/v2/strings" |
| 9 | ) |
| 10 | |
| 11 | // ToLower converts ascii string to lower-case. |
| 12 | // |
| 13 | // Deprecated: use [github.com/gofiber/utils/v2/strings.ToLower] instead. |
| 14 | // |
| 15 | //go:fix inline |
| 16 | func ToLower(b string) string { |
| 17 | return casestrings.ToLower(b) |
| 18 | } |
| 19 | |
| 20 | // ToUpper converts ascii string to upper-case. |
| 21 | // |
| 22 | // Deprecated: use [github.com/gofiber/utils/v2/strings.ToUpper] instead. |
| 23 | // |
| 24 | //go:fix inline |
| 25 | func ToUpper(b string) string { |
| 26 | return casestrings.ToUpper(b) |
| 27 | } |
| 28 | |
| 29 | // AddTrailingSlashString appends a trailing '/' to s if it does not already end with one. |
| 30 | // If the input already ends with '/', the original string is returned. |
| 31 | // A new string is returned only when a '/' needs to be appended. |
| 32 | func AddTrailingSlashString(s string) string { |
| 33 | n := len(s) |
| 34 | if n == 0 { |
| 35 | return "/" |
| 36 | } |
| 37 | if s[n-1] == '/' { |
| 38 | return s |
| 39 | } |
| 40 | buf := make([]byte, n+1) |
| 41 | copy(buf, s) |
| 42 | buf[n] = '/' |
| 43 | return UnsafeString(buf) |
| 44 | } |