File: strings.go

package info (click to toggle)
golang-github-gofiber-utils 2.0.2-1
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 432 kB
  • sloc: makefile: 40
file content (40 lines) | stat: -rw-r--r-- 1,119 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
// ⚡️ Fiber is an Express inspired web framework written in Go with ☕️
// 🤖 Github Repository: https://github.com/gofiber/fiber
// 📌 API Documentation: https://docs.gofiber.io

package utils

import (
	casestrings "github.com/gofiber/utils/v2/strings"
)

// ToLower converts ascii string to lower-case.
//
// Deprecated: use package "github.com/gofiber/utils/v2/strings" and call strings.ToLower.
func ToLower(b string) string {
	return casestrings.ToLower(b)
}

// ToUpper converts ascii string to upper-case.
//
// Deprecated: use package "github.com/gofiber/utils/v2/strings" and call strings.ToUpper.
func ToUpper(b string) string {
	return casestrings.ToUpper(b)
}

// AddTrailingSlashString appends a trailing '/' to s if it does not already end with one.
// If the input already ends with '/', the original string is returned.
// A new string is returned only when a '/' needs to be appended.
func AddTrailingSlashString(s string) string {
	n := len(s)
	if n == 0 {
		return "/"
	}
	if s[n-1] == '/' {
		return s
	}
	buf := make([]byte, n+1)
	copy(buf, s)
	buf[n] = '/'
	return UnsafeString(buf)
}