public
Description: Pretty url support for Ruby on Rails applications
Homepage: http://www.caring.com
Clone URL: git://github.com/caring/acts_as_url_param.git
Url utilities can now handle &, and & properly. It was stripping it so 
that "a & b" would turn into "a-amp-b", it will now do "a-and-b"
joshuabates (author)
Tue Feb 19 17:00:06 -0800 2008
commit  9c1d2a5bdebfae3a49a7727f126be58a7f585992
tree    9d30b10e4c837098ad103ac4db826329b63074a1
parent  8f476b6c333539785239274231c4e70044647d8d
...
17
18
19
 
20
21
22
...
17
18
19
20
21
22
23
0
@@ -17,6 +17,7 @@ module Caring
0
         s = s.downcase if options.fetch(:downcase, true)
0
         collapse = options.fetch(:collapse, true)
0
         default_regex = /[^'a-zA-Z0-9]#{"+" if collapse}/
0
+ s.gsub! /(&)|&/, 'and'
0
         replacements = options[:replacements] || { options.fetch(:char,"-") => default_regex, "" => /'#{"+" if collapse}/}
0
         replacements.each do |replacement, regex|
0
           s = s.gsub(regex,replacement)
...
5
6
7
 
8
9
10
...
5
6
7
8
9
10
11
0
@@ -5,6 +5,7 @@ class UrlUtilsTest < Test::Unit::TestCase
0
   
0
   def test_url_safe
0
     assert_equal "a1-b-z", url_safe("a1 b@ _Z!")
0
+ assert_equal "a-and-b-and-c-and-d", url_safe("a &amp; b &amp; c & d")
0
     assert_equal "a1-b-z", url_safe("a1 b@ - Z!")
0
     assert_equal 'a1#b#_Z', url_safe('a1 b@ _Z', :replacements => { '#', /[^a-zA-Z0-9_-]+/}, :downcase => false)
0
     assert_equal 'a1-b2---z9', url_safe('a1 b2 z9', :collapse => false)

Comments

    No one has commented yet.