mirror of
https://github.com/nbd-wtf/go-nostr.git
synced 2025-06-26 00:31:14 +02:00
nip54: normalize identifier.
This commit is contained in:
parent
7284ebcf13
commit
cff9af9aca
17
nip54/nip54.go
Normal file
17
nip54/nip54.go
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
package nip54
|
||||||
|
|
||||||
|
import (
|
||||||
|
"regexp"
|
||||||
|
"strings"
|
||||||
|
|
||||||
|
"golang.org/x/text/transform"
|
||||||
|
"golang.org/x/text/unicode/norm"
|
||||||
|
)
|
||||||
|
|
||||||
|
var nonLetter = regexp.MustCompile(`\W`)
|
||||||
|
|
||||||
|
func NormalizeIdentifier(name string) string {
|
||||||
|
res, _, _ := transform.Bytes(norm.NFKC, []byte(name))
|
||||||
|
str := nonLetter.ReplaceAllString(string(res), "-")
|
||||||
|
return strings.ToLower(str)
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user