From 60e7963141681895dcc81da944192c4292c6a20a Mon Sep 17 00:00:00 2001 From: wxiaoguang Date: Sun, 23 Apr 2023 19:16:30 +0800 Subject: [PATCH] Fix inconsistent wiki path converting. (#24277) The Infinite Monkey Random Typing catches a bug, inconsistent wiki path converting. Close #24276 Co-authored-by: silverwind Co-authored-by: Giteabot --- services/wiki/wiki_path.go | 2 +- services/wiki/wiki_test.go | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/services/wiki/wiki_path.go b/services/wiki/wiki_path.go index 45c6a5a84..f2600ad8b 100644 --- a/services/wiki/wiki_path.go +++ b/services/wiki/wiki_path.go @@ -72,7 +72,7 @@ func unescapeSegment(s string) (string, error) { } func escapeSegToWeb(s string, hadDashMarker bool) string { - if hadDashMarker || strings.Contains(s, "-") { + if hadDashMarker || strings.Contains(s, "-") || strings.HasSuffix(s, ".md") { s = addDashMarker(s) } else { s = strings.ReplaceAll(s, " ", "-") diff --git a/services/wiki/wiki_test.go b/services/wiki/wiki_test.go index 716ea6104..a781ebeda 100644 --- a/services/wiki/wiki_test.go +++ b/services/wiki/wiki_test.go @@ -35,6 +35,7 @@ func TestUserTitleToWebPath(t *testing.T) { } for _, test := range []test{ {"wiki-name", "wiki name"}, + {"title.md.-", "title.md"}, {"wiki-name.-", "wiki-name"}, {"the+wiki-name.-", "the wiki-name"}, {"a%2Fb", "a/b"},