1
0
Fork 0
mirror of https://github.com/binwiederhier/ntfy.git synced 2025-05-28 09:25:37 +02:00

WIP: Since ID, works

This commit is contained in:
Philipp Heckel 2022-02-26 15:57:10 -05:00
parent ce9e9f3e0d
commit 4af9c07577
7 changed files with 153 additions and 33 deletions

View file

@ -88,7 +88,20 @@ func RandomString(length int) string {
return string(b)
}
// DurationToHuman converts a duration to a human readable format
// ValidRandomString returns true if the given string matches the format created by RandomString
func ValidRandomString(s string, length int) bool {
if len(s) != length {
return false
}
for _, c := range strings.Split(s, "") {
if !strings.Contains(randomStringCharset, c) {
return false
}
}
return true
}
// DurationToHuman converts a duration to a human-readable format
func DurationToHuman(d time.Duration) (str string) {
if d == 0 {
return "0"