diff options
author | wxiaoguang <wxiaoguang@gmail.com> | 2023-04-23 19:16:30 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-04-23 07:16:30 -0400 |
commit | 60e7963141681895dcc81da944192c4292c6a20a (patch) | |
tree | ee3e0c4e04d301e294ad5c938364c596aea23734 | |
parent | 44e0cfa96e8f402b18b88be6ca5c2f368924bfa0 (diff) | |
download | gitea-60e7963141681895dcc81da944192c4292c6a20a.tar.gz gitea-60e7963141681895dcc81da944192c4292c6a20a.zip |
Fix inconsistent wiki path converting. (#24277)
The Infinite Monkey Random Typing catches a bug, inconsistent wiki path
converting.
Close #24276
Co-authored-by: silverwind <me@silverwind.io>
Co-authored-by: Giteabot <teabot@gitea.io>
-rw-r--r-- | services/wiki/wiki_path.go | 2 | ||||
-rw-r--r-- | services/wiki/wiki_test.go | 1 |
2 files changed, 2 insertions, 1 deletions
diff --git a/services/wiki/wiki_path.go b/services/wiki/wiki_path.go index 45c6a5a84e..f2600ad8ba 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 716ea6104a..a781ebeda4 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"}, |