Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/gohugoio/hugo.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>2020-05-21 12:25:00 +0300
committerBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>2020-05-24 13:35:45 +0300
commita985efcecf44afe1d252690ec0a00cf077974f44 (patch)
tree792e19ede943310f091977edb36962d1eee596f9 /helpers
parent6c3c6686f5d3c7155e2d455b07ac8ab70f42cb88 (diff)
Fix GetPage on section/bundle name overlaps
In the internal Radix we stored the directory based nodes without a traling slash, e.g. `/blog`. The original motivation was probably to make it easy to do prefix searching: Give me all ancestors. This, however have lead to some ambigouty with overlapping directory names. This particular problem was, however, not possible to work around in an easy way, so from now we store these as `/blog/`. Fixes #7301
Diffstat (limited to 'helpers')
-rw-r--r--helpers/path.go9
1 files changed, 9 insertions, 0 deletions
diff --git a/helpers/path.go b/helpers/path.go
index 29e1e6071..01c452607 100644
--- a/helpers/path.go
+++ b/helpers/path.go
@@ -665,3 +665,12 @@ func FileContainsAny(filename string, subslices [][]byte, fs afero.Fs) (bool, er
func Exists(path string, fs afero.Fs) (bool, error) {
return afero.Exists(fs, path)
}
+
+// AddTrailingSlash adds a trailing Unix styled slash (/) if not already
+// there.
+func AddTrailingSlash(path string) string {
+ if !strings.HasSuffix(path, "/") {
+ path += "/"
+ }
+ return path
+}