Simplify GetDottedRelativePath - hugo - [fork] hugo port for 9front
HTML git clone git@git.drkhsh.at/hugo.git
DIR Log
DIR Files
DIR Refs
DIR Submodules
DIR README
DIR LICENSE
---
DIR commit 0a768ec95fc44c680c69530e515e11a02196b3d8
DIR parent 8d86f1ec6ed7a707c995548799c924ff3948acfc
HTML Author: Bjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>
Date: Sat, 19 Mar 2016 17:17:17 +0100
Simplify GetDottedRelativePath
Diffstat:
M helpers/path.go | 11 ++++++-----
1 file changed, 6 insertions(+), 5 deletions(-)
---
DIR diff --git a/helpers/path.go b/helpers/path.go
@@ -199,18 +199,19 @@ var isFileRe = regexp.MustCompile(".*\\..{1,6}$")
// Expects a relative path starting after the content directory.
func GetDottedRelativePath(inPath string) string {
inPath = filepath.Clean(filepath.FromSlash(inPath))
+
if inPath == "." {
return "./"
}
- isFile := isFileRe.MatchString(inPath)
- if !isFile {
- if !strings.HasSuffix(inPath, FilePathSeparator) {
- inPath += FilePathSeparator
- }
+
+ if !isFileRe.MatchString(inPath) && !strings.HasSuffix(inPath, FilePathSeparator) {
+ inPath += FilePathSeparator
}
+
if !strings.HasPrefix(inPath, FilePathSeparator) {
inPath = FilePathSeparator + inPath
}
+
dir, _ := filepath.Split(inPath)
sectionCount := strings.Count(dir, FilePathSeparator)