Never remove trailing slash in RelPermalink

Fixed #1174
This commit is contained in:
bep
2015-05-27 20:41:25 +02:00
parent beffe756a9
commit be964e95a1
3 changed files with 8 additions and 0 deletions

View File

@@ -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
}

View File

@@ -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},
}