mirror of
https://github.com/binwiederhier/ntfy.git
synced 2026-01-18 16:17:26 +01:00
Remove UUID
This commit is contained in:
@@ -7,8 +7,6 @@ import (
|
||||
"encoding/hex"
|
||||
"fmt"
|
||||
"hash/adler32"
|
||||
|
||||
"github.com/google/uuid"
|
||||
)
|
||||
|
||||
func sha512sum(input string) string {
|
||||
@@ -30,8 +28,3 @@ func adler32sum(input string) string {
|
||||
hash := adler32.Checksum([]byte(input))
|
||||
return fmt.Sprintf("%d", hash)
|
||||
}
|
||||
|
||||
// uuidv4 provides a safe and secure UUID v4 implementation
|
||||
func uuidv4() string {
|
||||
return uuid.New().String()
|
||||
}
|
||||
|
||||
@@ -31,24 +31,3 @@ func TestAdler32Sum(t *testing.T) {
|
||||
t.Error(err)
|
||||
}
|
||||
}
|
||||
|
||||
func TestUUIDGeneration(t *testing.T) {
|
||||
tpl := `{{uuidv4}}`
|
||||
out, err := runRaw(tpl, nil)
|
||||
if err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
|
||||
if len(out) != 36 {
|
||||
t.Error("Expected UUID of length 36")
|
||||
}
|
||||
|
||||
out2, err := runRaw(tpl, nil)
|
||||
if err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
|
||||
if out == out2 {
|
||||
t.Error("Expected subsequent UUID generations to be different")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -58,10 +58,7 @@ var genericMap = map[string]any{
|
||||
},
|
||||
"substr": substring,
|
||||
// Switch order so that "foo" | repeat 5
|
||||
"repeat": func(count int, str string) string { return strings.Repeat(str, count) },
|
||||
// Deprecated: Use trimAll.
|
||||
"trimall": func(a, b string) string { return strings.Trim(b, a) },
|
||||
// Switch order so that "$foo" | trimall "$"
|
||||
"repeat": func(count int, str string) string { return strings.Repeat(str, count) },
|
||||
"trimAll": func(a, b string) string { return strings.Trim(b, a) },
|
||||
"trimSuffix": func(a, b string) string { return strings.TrimSuffix(b, a) },
|
||||
"trimPrefix": func(a, b string) string { return strings.TrimPrefix(b, a) },
|
||||
@@ -220,9 +217,6 @@ var genericMap = map[string]any{
|
||||
"chunk": chunk,
|
||||
"mustChunk": mustChunk,
|
||||
|
||||
// UUIDs:
|
||||
"uuidv4": uuidv4,
|
||||
|
||||
// Flow Control:
|
||||
"fail": func(msg string) (string, error) { return "", errors.New(msg) },
|
||||
|
||||
|
||||
Reference in New Issue
Block a user