Betterify sanitization

This commit is contained in:
2024-11-05 16:03:32 +01:00
parent 8ab4b4c280
commit 9b38ea7068

View File

@@ -6,6 +6,7 @@ import (
"log" "log"
"os" "os"
"path/filepath" "path/filepath"
"regexp"
"strings" "strings"
"github.com/gen2brain/beeep" "github.com/gen2brain/beeep"
@@ -78,11 +79,10 @@ func DownloadR(url string) error {
return nil return nil
} }
var re = regexp.MustCompile(`[#!$%&/()";:?;,]`)
func Sanitize(s string) string { func Sanitize(s string) string {
s = strings.ReplaceAll(s, "&", "and") s = strings.ReplaceAll(s, "&", "and")
s = strings.ReplaceAll(s, "?", "") s = re.ReplaceAllString(s, "")
s = strings.ReplaceAll(s, ":", "")
s = strings.ReplaceAll(s, ";", "")
s = strings.ReplaceAll(s, ",", "")
return s return s
} }