Skip to content

Commit

Permalink
DRY'd up uri path escaping.
Browse files Browse the repository at this point in the history
  • Loading branch information
trevorrowe committed Oct 16, 2015
1 parent 534a24d commit d0661e7
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 5 deletions.
2 changes: 1 addition & 1 deletion aws-sdk-core/lib/aws-sdk-core/signers/v4.rb
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ def path(uri)
if @service_name == 's3'
path
else
path.gsub(/[^\/]+/) { |segment| Seahorse::Util.uri_escape(segment) }
Seahorse::Util.uri_path_escape(path)
end
end

Expand Down
4 changes: 4 additions & 0 deletions aws-sdk-core/lib/seahorse/util.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,10 @@ def uri_escape(string)
CGI.escape(string.encode('UTF-8')).gsub('+', '%20').gsub('%7E', '~')
end

def uri_path_escape(path)
path.gsub(/[^\/]+/) { |part| uri_escape(part) }
end

end

@irregular_inflections = {}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ def s3_bucket_url
url.host = "#{name}.#{url.host}"
else
url.path += '/' unless url.path[-1] == '/'
url.path += path_escape(name)
url.path += Seahorse::Util.uri_path_escape(name)
end
url.to_s
end
Expand All @@ -97,9 +97,6 @@ def bucket_as_hostname?(https)
!client.config.force_path_style
end

def path_escape(name)
name.gsub(/[^\/]+/) {|part| Seahorse::Util.uri_escape(part) }
end
end
end
end

0 comments on commit d0661e7

Please sign in to comment.