/
githubmirror
/
photoprism
Обзор
Документация
Войти
/
githubmirror
/
photoprism
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
develop
pkg/http/header/id.go
34 строки
594 B
Michael Mayer
Pkg: Move /service/http/... to /http/... and add package /http/dns
19 окт 2025, 22:08
19 окт 2025, 22:08
a921f82
Код
Авторство
О чём код?
package header import "strings" // ID sanitizes identifier tokens, for example, a session ID, a UUID, or some other string ID. func ID(s string) string { if s == "" || len(s) > 4096 { return "" } var prev rune // Remove all invalid characters. s = strings.Map(func(r rune) rune { if r == ' ' && (prev == 0 || prev == ' ') { return -1 } prev = r switch r { case ' ', '"', '-', '+', '/', '=', '#', '$', '@', ':', ';', '_', '.': return r } if (r < '0' || r > '9') && (r < 'a' || r > 'z') && (r < 'A' || r > 'Z') { return -1 } return r }, s) return s }