mirror of
https://github.com/gohugoio/hugo.git
synced 2024-11-07 20:30:36 -05:00
Minor polish in path/url
This commit is contained in:
parent
9e688507a7
commit
2ec046afb1
2 changed files with 4 additions and 9 deletions
|
@ -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 {
|
||||
|
|
|
@ -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
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue