Skip to content
Snippets Groups Projects
Commit 6e9891f4 authored by ale's avatar ale
Browse files

Generate the SRI map in sorted order

Being consistent across runs avoids generating spurious git changes.
parent c8f18956
Branches
No related tags found
1 merge request!6Refactor the login handler
// +build ignore
package main package main
import ( import (
...@@ -10,6 +12,7 @@ import ( ...@@ -10,6 +12,7 @@ import (
"log" "log"
"os" "os"
"path/filepath" "path/filepath"
"sort"
"strings" "strings"
) )
...@@ -65,8 +68,14 @@ func codegen(w io.Writer, m map[string]string) { ...@@ -65,8 +68,14 @@ func codegen(w io.Writer, m map[string]string) {
io.WriteString(w, ` io.WriteString(w, `
var sriMap = map[string]string{ var sriMap = map[string]string{
`) `)
for k, v := range m { // Dump the map in sorted order.
fmt.Fprintf(w, "\t%q: %q,\n", k, v) var keys []string
for k := range m {
keys = append(keys, k)
}
sort.Strings(keys)
for _, k := range keys {
fmt.Fprintf(w, "\t%q: %q,\n", k, m[k])
} }
io.WriteString(w, "}\n") io.WriteString(w, "}\n")
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment