Browse Source

wiki: remove redundant string replace (#3754)

pull/3785/merge
Unknwon 8 years ago
parent
commit
c2277796e4
No known key found for this signature in database
GPG Key ID: 7A02C406FAC875A2
  1. 4
      models/wiki.go

4
models/wiki.go

@ -25,14 +25,14 @@ var wikiWorkingPool = sync.NewExclusivePool()
// ToWikiPageURL formats a string to corresponding wiki URL name. // ToWikiPageURL formats a string to corresponding wiki URL name.
func ToWikiPageURL(name string) string { func ToWikiPageURL(name string) string {
return url.QueryEscape(strings.Replace(name, " ", "-", -1)) return url.QueryEscape(name)
} }
// ToWikiPageName formats a URL back to corresponding wiki page name, // ToWikiPageName formats a URL back to corresponding wiki page name,
// and removes leading characters './' to prevent changing files // and removes leading characters './' to prevent changing files
// that are not belong to wiki repository. // that are not belong to wiki repository.
func ToWikiPageName(urlString string) string { func ToWikiPageName(urlString string) string {
name, _ := url.QueryUnescape(strings.Replace(urlString, "-", " ", -1)) name, _ := url.QueryUnescape(urlString)
return strings.Replace(strings.TrimLeft(name, "./"), "/", " ", -1) return strings.Replace(strings.TrimLeft(name, "./"), "/", " ", -1)
} }

Loading…
Cancel
Save