summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--app/helpers/application_helper.rb3
-rw-r--r--test/unit/helpers/application_helper_test.rb7
2 files changed, 9 insertions, 1 deletions
diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb
index 7e528eb1a..a57157c29 100644
--- a/app/helpers/application_helper.rb
+++ b/app/helpers/application_helper.rb
@@ -369,7 +369,8 @@ module ApplicationHelper
end
def to_path_param(path)
- path.to_s.split(%r{[/\\]}).select {|p| !p.blank?}
+ str = path.to_s.split(%r{[/\\]}).select{|p| !p.blank?}.join("/")
+ str.blank? ? nil : str
end
def pagination_links_full(paginator, count=nil, options={})
diff --git a/test/unit/helpers/application_helper_test.rb b/test/unit/helpers/application_helper_test.rb
index 6dea2cf57..1a9d4642a 100644
--- a/test/unit/helpers/application_helper_test.rb
+++ b/test/unit/helpers/application_helper_test.rb
@@ -725,6 +725,13 @@ EXPECTED
assert_equal expected.gsub(%r{[\r\n\t]}, ''), textilizable(raw).gsub(%r{[\r\n\t]}, '')
end
+ def test_to_path_param
+ assert_equal 'test1/test2', to_path_param('test1/test2')
+ assert_equal 'test1/test2', to_path_param('/test1/test2/')
+ assert_equal 'test1/test2', to_path_param('//test1/test2/')
+ assert_equal nil, to_path_param('/')
+ end
+
def test_wiki_links_in_tables
to_test = {"|[[Page|Link title]]|[[Other Page|Other title]]|\n|Cell 21|[[Last page]]|" =>
'<tr><td><a href="/projects/ecookbook/wiki/Page" class="wiki-page new">Link title</a></td>' +