Skip to content
Closed
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions models/wiki.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,12 @@ func WikiNameToFilename(name string) string {
return url.QueryEscape(name) + ".md"
}

// WikiNameToFilenameRaw converts a wiki name to its corresponding raw filename.
func WikiNameToFilenameRaw(name string) string {
name = strings.Replace(name, " ", "-", -1)
return url.QueryEscape(name)
}

// WikiFilenameToName converts a wiki filename to its corresponding page name.
func WikiFilenameToName(filename string) (string, error) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

WikiNameToFilename should reuse WikiNameToFilenameRaw

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the review.
Now that I look at the code of models/wiki.go again I can't see the difference between WikiNameToFilenameRawand WikiNameToSubURL. I think I totally duplicated a method that was already in place... Doh.
I will fix that.

if !strings.HasSuffix(filename, ".md") {
Expand Down
2 changes: 1 addition & 1 deletion routers/repo/wiki.go
Original file line number Diff line number Diff line change
Expand Up @@ -294,7 +294,7 @@ func WikiRaw(ctx *context.Context) {
if strings.HasSuffix(providedPath, ".md") {
providedPath = providedPath[:len(providedPath)-3]
}
wikiPath := models.WikiNameToFilename(providedPath)
wikiPath := models.WikiNameToFilenameRaw(providedPath)
var entry *git.TreeEntry
if commit != nil {
entry, err = findEntryForFile(commit, wikiPath)
Expand Down