Auth: Refactor cluster configuration and provisioning API endpoints #98

Signed-off-by: Michael Mayer <michael@photoprism.app>
This commit is contained in:
Michael Mayer
2025-09-24 08:28:38 +02:00
parent 3baabebf50
commit 61ced7119c
242 changed files with 4477 additions and 1789 deletions

View File

@@ -1,18 +1,25 @@
package clean
// ASCII removes all non-ascii characters from a string and returns it.
// ASCII removes all non-ASCII bytes from a string.
// Fast path: return the original string when it already contains only ASCII.
func ASCII(s string) string {
if s == "" {
return ""
}
result := make([]rune, 0, len(s))
for _, r := range s {
if r <= 127 {
result = append(result, r)
// Fast path: all bytes < 128 → no allocation.
for i := 0; i < len(s); i++ {
if s[i] >= 0x80 { // non-ASCII
// Slow path: filter into a new byte slice.
dst := make([]byte, 0, len(s))
for j := 0; j < len(s); j++ {
b := s[j]
if b < 0x80 {
dst = append(dst, b)
}
}
return string(dst)
}
}
return string(result)
return s
}