Skip to content

Instantly share code, notes, and snippets.

@rgrove
Created April 15, 2009 05:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rgrove/95636 to your computer and use it in GitHub Desktop.
Save rgrove/95636 to your computer and use it in GitHub Desktop.
diff --git a/lib/innate/helper/link.rb b/lib/innate/helper/link.rb
index 08b8b2d..db0113b 100644
--- a/lib/innate/helper/link.rb
+++ b/lib/innate/helper/link.rb
@@ -28,12 +28,12 @@ module Innate
hashes, names = args.partition{|arg| arg.respond_to?(:merge!) }
hashes.each{|to_merge| hash.merge!(to_merge) }
+ escape = Rack::Utils.method(:escape)
location = route_location(self)
- front = Array[location, name, *names].join('/').squeeze('/')
+ front = Array[location, name, *names.map{|n| escape[n]}].join('/').squeeze('/')
return URI(front) if hash.empty?
- escape = Rack::Utils.method(:escape)
query = hash.map{|k, v| "#{escape[k]}=#{escape[v]}" }.join(';')
URI("#{front}?#{query}")
end
diff --git a/spec/innate/helper/link.rb b/spec/innate/helper/link.rb
index b160cd2..9c9efda 100644
--- a/spec/innate/helper/link.rb
+++ b/spec/innate/helper/link.rb
@@ -56,6 +56,14 @@ describe Innate::Helper::Link do
Two.route(:foo, :bar).should == URI('/two/foo/bar')
end
+ should 'respond with URI for node with path /foo/bar+baz' do
+ One.route('/foo/bar+baz').should == URI('/foo/bar+baz')
+ One.route(:foo, 'bar baz').should == URI('/foo/bar+baz')
+
+ Two.route('/foo/bar+baz').should == URI('/two/foo/bar+baz')
+ Two.route(:foo, 'bar baz').should == URI('/two/foo/bar+baz')
+ end
+
should 'respond with URI for node with GET params' do
One.route('/', :a => :b).should == URI('/?a=b')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment