ref: 0a768ec95fc44c680c69530e515e11a02196b3d8
parent: 8d86f1ec6ed7a707c995548799c924ff3948acfc
author: Bjørn Erik Pedersen <[email protected]>
date: Sat Mar 19 13:17:17 EDT 2016
Simplify GetDottedRelativePath
--- a/helpers/path.go
+++ b/helpers/path.go
@@ -199,18 +199,19 @@
// 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)