Use clean_url helper.

This commit is contained in:
Bart Kamphorst
2019-10-08 20:26:59 +02:00
parent 5dd6c40933
commit f0dbc2801b
2 changed files with 2 additions and 2 deletions
+1 -1
View File
@@ -279,7 +279,7 @@ module Precious
# Renaming preserves format, so add the page's format to the renamed path to retrieve the renamed page
new_path = "#{rename}.#{Gollum::Page.format_to_ext(page.format)}"
# Add a redirect from the old page to the new
wiki.add_redirect(page.url_path, new_path.gsub(/(^\/)/, '')) if @redirects_enabled
wiki.add_redirect(page.url_path, clean_url(new_path)) if @redirects_enabled
page = wiki_page(new_path).page
return if page.nil?
+1 -1
View File
@@ -17,7 +17,7 @@ module Precious
# Remove all slashes from the start of string.
# Remove all double slashes
def clean_url url
def clean_url(url)
return url if url.nil?
url.gsub('%2F', '/').gsub(/^\/+/, '').gsub('//', '/')
end