summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>2016-03-19 17:17:17 +0100
committerBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>2016-03-19 17:17:17 +0100
commit0a768ec95fc44c680c69530e515e11a02196b3d8 (patch)
tree883c475a19c047ce3bfb975c5e12e65d8f9b517e
parent8d86f1ec6ed7a707c995548799c924ff3948acfc (diff)
Simplify GetDottedRelativePath
-rw-r--r--helpers/path.go11
1 files changed, 6 insertions, 5 deletions
diff --git a/helpers/path.go b/helpers/path.go
index 75e46f552..d9efeb24e 100644
--- 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)