Use clean_url helper.
This commit is contained in:
+1
-1
@@ -279,7 +279,7 @@ module Precious
|
|||||||
# Renaming preserves format, so add the page's format to the renamed path to retrieve the renamed page
|
# 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)}"
|
new_path = "#{rename}.#{Gollum::Page.format_to_ext(page.format)}"
|
||||||
# Add a redirect from the old page to the new
|
# 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
|
page = wiki_page(new_path).page
|
||||||
return if page.nil?
|
return if page.nil?
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ module Precious
|
|||||||
|
|
||||||
# Remove all slashes from the start of string.
|
# Remove all slashes from the start of string.
|
||||||
# Remove all double slashes
|
# Remove all double slashes
|
||||||
def clean_url url
|
def clean_url(url)
|
||||||
return url if url.nil?
|
return url if url.nil?
|
||||||
url.gsub('%2F', '/').gsub(/^\/+/, '').gsub('//', '/')
|
url.gsub('%2F', '/').gsub(/^\/+/, '').gsub('//', '/')
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user