Skip to content

Commit

Permalink
use uri unescape directly
Browse files Browse the repository at this point in the history
  • Loading branch information
Josh Hull committed May 31, 2011
1 parent 977fbe2 commit 73c71ed
Show file tree
Hide file tree
Showing 5 changed files with 5 additions and 10 deletions.
5 changes: 0 additions & 5 deletions lib/http_router/node.rb
Expand Up @@ -66,10 +66,5 @@ def add(matcher)
@matchers << matcher unless matcher.usable?(@matchers.last)
@matchers.last
end

def unescape(val)
val.to_s.gsub!(/((?:%[0-9a-fA-F]{2})+)/n){ [$1.delete('%')].pack('H*') }
val
end
end
end
2 changes: 1 addition & 1 deletion lib/http_router/node/glob.rb
Expand Up @@ -6,7 +6,7 @@ def [](request)
request.params << []
remaining_parts = request.path.dup
until remaining_parts.empty?
request.params[-1] << unescape(remaining_parts.shift)
request.params[-1] << URI.unescape(remaining_parts.shift)
request.path = remaining_parts
super(request)
end
Expand Down
2 changes: 1 addition & 1 deletion lib/http_router/node/glob_regex.rb
Expand Up @@ -2,7 +2,7 @@ class HttpRouter
class Node
class GlobRegex < SpanningRegex
def add_params(request)
@capturing_indicies.each { |idx| request.params << unescape(match[idx].split('/')) }
@capturing_indicies.each { |idx| request.params << URI.unescape(match[idx].split('/')) }
end
end
end
Expand Down
4 changes: 2 additions & 2 deletions lib/http_router/node/regex.rb
Expand Up @@ -19,8 +19,8 @@ def [](request)
end

def add_params(request, match)
@splitting_indicies.each { |idx| request.params << unescape(match[idx]).split(/\//) } if @splitting_indicies
@capturing_indicies.each { |idx| request.params << unescape(match[idx]) }
@splitting_indicies.each { |idx| request.params << URI.unescape(match[idx]).split(/\//) } if @splitting_indicies
@capturing_indicies.each { |idx| request.params << URI.unescape(match[idx]) }
end

def usuable?(other)
Expand Down
2 changes: 1 addition & 1 deletion lib/http_router/node/variable.rb
Expand Up @@ -4,7 +4,7 @@ class Variable < Node
def [](request)
unless request.path.empty?
request = request.clone
request.params << unescape(request.path.shift)
request.params << URI.unescape(request.path.shift)
super(request)
end
end
Expand Down

0 comments on commit 73c71ed

Please sign in to comment.