diff --git a/lib/gollum/app.rb b/lib/gollum/app.rb index d58b65a1..349481df 100644 --- a/lib/gollum/app.rb +++ b/lib/gollum/app.rb @@ -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? diff --git a/lib/gollum/helpers.rb b/lib/gollum/helpers.rb index d0dad08e..f94ecf8a 100644 --- a/lib/gollum/helpers.rb +++ b/lib/gollum/helpers.rb @@ -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