diff options
author | bep <bjorn.erik.pedersen@gmail.com> | 2015-01-20 22:45:03 +0300 |
---|---|---|
committer | bep <bjorn.erik.pedersen@gmail.com> | 2015-01-20 22:45:03 +0300 |
commit | 2ec046afb18adbf580bf0d173201abfb5f691d58 (patch) | |
tree | d87890b6aca39dd4b17d74f2a7bd46dcceca9a35 /helpers | |
parent | 9e688507a792ceb4f5dacb0c9ccae621fb2ff804 (diff) |
Minor polish in path/url
Diffstat (limited to 'helpers')
-rw-r--r-- | helpers/path.go | 11 | ||||
-rw-r--r-- | helpers/url.go | 2 |
2 files changed, 4 insertions, 9 deletions
diff --git a/helpers/path.go b/helpers/path.go index 309257668..165ce2314 100644 --- a/helpers/path.go +++ b/helpers/path.go @@ -48,11 +48,6 @@ func MakeTitle(inpath string) string { return strings.Replace(strings.TrimSpace(inpath), "-", " ", -1) } -// unused -//func Sanitize(s string) string { -// return sanitizeRegexp.ReplaceAllString(s, "") -//} - func UnicodeSanitize(s string) string { source := []rune(s) target := make([]rune, 0, len(source)) @@ -183,10 +178,10 @@ func FileAndExt(in string) (name string, ext string) { ext = filepath.Ext(in) base := filepath.Base(in) // path.Base strips any trailing slash! - return FileAndExtSep(in, ext, base, FilePathSeparator), ext + return extractFilename(in, ext, base, FilePathSeparator), ext } -func FileAndExtSep(in, ext, base, pathSeparator string) (name string) { +func extractFilename(in, ext, base, pathSeparator string) (name string) { // No file name cases. These are defined as: // 1. any "in" path that ends in a pathSeparator @@ -223,7 +218,7 @@ func GetRelativePath(path, base string) (final string, err error) { return name, nil } -// Given a source path, determine the section. +// GuessSection returns the section given a source path. // A section is the part between the root slash and the second slash // or before the first slash. func GuessSection(in string) string { diff --git a/helpers/url.go b/helpers/url.go index ec5e81229..46bc951f4 100644 --- a/helpers/url.go +++ b/helpers/url.go @@ -168,5 +168,5 @@ func ResourceAndExt(in string) (name string, ext string) { ext = path.Ext(in) base := path.Base(in) - return FileAndExtSep(in, ext, base, "/"), ext + return extractFilename(in, ext, base, "/"), ext } |