diff --git a/util.go b/util.go index f709513..13508fd 100644 --- a/util.go +++ b/util.go @@ -36,10 +36,8 @@ import ( "bufio" "crypto/rand" "crypto/rsa" - "crypto/sha512" "database/sql" "fmt" - "io/ioutil" "net" "os" "os/signal" @@ -52,24 +50,8 @@ import ( "humungus.tedunangst.com/r/webs/login" ) -var savedassetparams = make(map[string]string) - var re_plainname = regexp.MustCompile("^[[:alnum:]_-]+$") -func getassetparam(file string) string { - if p, ok := savedassetparams[file]; ok { - return p - } - data, err := ioutil.ReadFile(file) - if err != nil { - return "" - } - hasher := sha512.New() - hasher.Write(data) - - return fmt.Sprintf("?v=%.8x", hasher.Sum(nil)) -} - var dbtimeformat = "2006-01-02 15:04:05" var alreadyopendb *sql.DB diff --git a/web.go b/web.go index 398cbde..4eec440 100644 --- a/web.go +++ b/web.go @@ -17,6 +17,7 @@ package main import ( "bytes" + "crypto/sha512" "database/sql" "fmt" "html/template" @@ -2692,6 +2693,22 @@ func emuinit() { }) } +var savedassetparams = make(map[string]string) + +func getassetparam(file string) string { + if p, ok := savedassetparams[file]; ok { + return p + } + data, err := os.ReadFile(file) + if err != nil { + return "" + } + hasher := sha512.New() + hasher.Write(data) + + return fmt.Sprintf("?v=%.8x", hasher.Sum(nil)) +} + func serve() { db := opendatabase() login.Init(login.InitArgs{Db: db, Logger: ilog, Insecure: develMode, SameSiteStrict: !develMode})