Skip to content

Commit

Permalink
Merge pull request #68 from substancelab/encoding_and_decoding
Browse files Browse the repository at this point in the history
Extract methods to decode and encode URI segments
  • Loading branch information
koppen authored Dec 6, 2024
2 parents 916ac7f + ef05369 commit cebbe56
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion lib/route_downcaser/downcase_route_middleware.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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
Expand Down

0 comments on commit cebbe56

Please sign in to comment.