ref: 2ec046afb18adbf580bf0d173201abfb5f691d58
parent: 9e688507a792ceb4f5dacb0c9ccae621fb2ff804
author: bep <[email protected]>
date: Tue Jan 20 15:45:03 EST 2015
Minor polish in path/url
--- a/helpers/path.go
+++ b/helpers/path.go
@@ -48,11 +48,6 @@
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 @@
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 @@
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 {
--- a/helpers/url.go
+++ b/helpers/url.go
@@ -168,5 +168,5 @@
ext = path.Ext(in)
base := path.Base(in)
- return FileAndExtSep(in, ext, base, "/"), ext
+ return extractFilename(in, ext, base, "/"), ext
}