From f0dbc2801bd54c35302259c7791476d6c1589aa3 Mon Sep 17 00:00:00 2001 From: Bart Kamphorst Date: Tue, 8 Oct 2019 20:26:59 +0200 Subject: [PATCH] Use clean_url helper. --- lib/gollum/app.rb | 2 +- lib/gollum/helpers.rb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) 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