Skip to content

Commit 3ae4823

Browse files
author
Aly Sewelam
committed
Add org file path resolution for Web and Git paths
1 parent 36c23b8 commit 3ae4823

File tree

1 file changed

+11
-4
lines changed

1 file changed

+11
-4
lines changed

services/wiki/wiki_path.go

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -94,8 +94,10 @@ func WebPathSegments(s WebPath) []string {
9494
}
9595

9696
func WebPathToGitPath(s WebPath) string {
97-
if strings.HasSuffix(string(s), ".md") {
98-
ret, _ := url.PathUnescape(string(s))
97+
str := string(s)
98+
// Accept only .md or .org directly
99+
if strings.HasSuffix(str, ".md") || strings.HasSuffix(str, ".org") {
100+
ret, _ := url.PathUnescape(str)
99101
return util.PathJoinRelX(ret)
100102
}
101103

@@ -111,10 +113,15 @@ func WebPathToGitPath(s WebPath) string {
111113
}
112114

113115
func GitPathToWebPath(s string) (wp WebPath, err error) {
114-
if !strings.HasSuffix(s, ".md") {
116+
// Trim .md or .org suffix if present
117+
if strings.HasSuffix(s, ".md") {
118+
s = strings.TrimSuffix(s, ".md")
119+
} else if strings.HasSuffix(s, ".org") {
120+
s = strings.TrimSuffix(s, ".org")
121+
} else {
122+
// If it doesn't end with .md or .org, it's not a valid wiki file
115123
return "", repo_model.ErrWikiInvalidFileName{FileName: s}
116124
}
117-
s = strings.TrimSuffix(s, ".md")
118125
a := strings.Split(s, "/")
119126
for i := range a {
120127
shouldAddDashMarker := hasDashMarker(a[i])

0 commit comments

Comments
 (0)