Fixed hashing of passwords, Closes #3

This commit is contained in:
Torkel Ödegaard
2015-01-08 09:00:00 +01:00
parent 6d814af0cc
commit 3226a3a58e
13 changed files with 138 additions and 60 deletions

37
pkg/util/url.go Normal file
View File

@@ -0,0 +1,37 @@
package util
import (
"net/url"
"strings"
)
type UrlQueryReader struct {
values url.Values
}
func NewUrlQueryReader(url *url.URL) *UrlQueryReader {
return &UrlQueryReader{
values: url.Query(),
}
}
func (r *UrlQueryReader) Get(name string, def string) string {
val := r.values[name]
if len(val) == 0 {
return def
}
return val[0]
}
func JoinUrlFragments(a, b string) string {
aslash := strings.HasSuffix(a, "/")
bslash := strings.HasPrefix(b, "/")
switch {
case aslash && bslash:
return a + b[1:]
case !aslash && !bslash:
return a + "/" + b
}
return a + b
}