diff options
author | n1xx1 <[email protected]> | 2024-10-14 12:08:31 +0200 |
---|---|---|
committer | Bjørn Erik Pedersen <[email protected]> | 2024-10-15 10:28:00 +0200 |
commit | e7d0757f95b3a258282129a74946cd9904070721 (patch) | |
tree | 668d01c43bcdca9dd442c374cbc15d920897d6a4 /resources/page/permalinks_test.go | |
parent | 6b5e117a1213eecf1320aad292a0979c67f5179d (diff) | |
download | hugo-e7d0757f95b3a258282129a74946cd9904070721.tar.gz hugo-e7d0757f95b3a258282129a74946cd9904070721.zip |
resources/page: Allow colons in permalinks to be escaped
Updates #12918
Diffstat (limited to 'resources/page/permalinks_test.go')
-rw-r--r-- | resources/page/permalinks_test.go | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/resources/page/permalinks_test.go b/resources/page/permalinks_test.go index a3a45bb88..9a8ac51f2 100644 --- a/resources/page/permalinks_test.go +++ b/resources/page/permalinks_test.go @@ -44,6 +44,8 @@ var testdataPermalinks = []struct { {"/:sections/", true, "/a/b/c/"}, // Sections {"/:sections[last]/", true, "/c/"}, // Sections {"/:sections[0]/:sections[last]/", true, "/a/c/"}, // Sections + {"/\\:filename", true, "/:filename"}, // Escape sequence + {"/special\\::slug/", true, "/special:the-slug/"}, // Escape sequence // Failures {"/blog/:fred", false, ""}, @@ -117,6 +119,7 @@ func TestPermalinkExpansionMultiSection(t *testing.T) { "posts": "/:slug", "blog": "/:section/:year", "recipes": "/:slugorfilename", + "special": "/special\\::slug", }, } expander, err := NewPermalinkExpander(urlize, permalinksConfig) @@ -137,6 +140,10 @@ func TestPermalinkExpansionMultiSection(t *testing.T) { expanded, err = expander.Expand("recipes", page_slug_fallback) c.Assert(err, qt.IsNil) c.Assert(expanded, qt.Equals, "/page-filename") + + expanded, err = expander.Expand("special", page) + c.Assert(err, qt.IsNil) + c.Assert(expanded, qt.Equals, "/special:the-slug") } func TestPermalinkExpansionConcurrent(t *testing.T) { |