diff --git a/lib/route_downcaser/downcase_route_middleware.rb b/lib/route_downcaser/downcase_route_middleware.rb index 7037128..ca00ea6 100644 --- a/lib/route_downcaser/downcase_route_middleware.rb +++ b/lib/route_downcaser/downcase_route_middleware.rb @@ -62,7 +62,7 @@ def downcased_path(uri) end def downcase_path_segment(segment) - URI.encode_www_form_component(URI.decode_www_form_component(segment).downcase) + uri_encode(uri_decode(segment).downcase) end def path(uri) @@ -77,6 +77,14 @@ def has_querystring?(uri) uri_items(uri).length > 1 end + def uri_decode(uri_segment) + URI.decode_www_form_component(uri_segment) + end + + def uri_encode(uri_segment) + URI.encode_www_form_component(uri_segment) + end + def uri_items(uri) uri.split("?", 2) end