diff --git a/nip54/nip54.go b/nip54/nip54.go new file mode 100644 index 0000000..4b06f14 --- /dev/null +++ b/nip54/nip54.go @@ -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) +}