summaryrefslogtreecommitdiffstats
path: root/helpers
diff options
context:
space:
mode:
authorbep <bjorn.erik.pedersen@gmail.com>2015-05-27 20:41:25 +0200
committerbep <bjorn.erik.pedersen@gmail.com>2015-05-27 20:41:43 +0200
commitbe964e95a13bce974e4c7af4118979d6fea71112 (patch)
tree34b01c835160369afbaf8bcdf2597793e7d617eb /helpers
parentbeffe756a91f4c47e8e8fa622b9a52d213a8c821 (diff)
Never remove trailing slash in RelPermalink
Fixed #1174
Diffstat (limited to 'helpers')
-rw-r--r--helpers/path.go4
-rw-r--r--helpers/path_test.go1
2 files changed, 5 insertions, 0 deletions
diff --git a/helpers/path.go b/helpers/path.go
index 71ffee980..0dee8db4c 100644
--- a/helpers/path.go
+++ b/helpers/path.go
@@ -331,6 +331,10 @@ func GetRelativePath(path, base string) (final string, err error) {
if err != nil {
return "", err
}
+
+ if strings.HasSuffix(path, "/") && !strings.HasSuffix(name, "/") {
+ name += "/"
+ }
return name, nil
}
diff --git a/helpers/path_test.go b/helpers/path_test.go
index c9b4beac1..cb8714266 100644
--- a/helpers/path_test.go
+++ b/helpers/path_test.go
@@ -65,6 +65,7 @@ func TestGetRelativePath(t *testing.T) {
expect interface{}
}{
{filepath.FromSlash("/a/b"), filepath.FromSlash("/a"), filepath.FromSlash("b")},
+ {filepath.FromSlash("/a/b/c/"), filepath.FromSlash("/a"), filepath.FromSlash("b/c/")},
{filepath.FromSlash("/c"), filepath.FromSlash("/a/b"), filepath.FromSlash("../../c")},
{filepath.FromSlash("/c"), "", false},
}