lib/fog/aws/signaturev4.rb in fog-aws-0.4.0 vs lib/fog/aws/signaturev4.rb in fog-aws-0.4.1
- old
+ new
@@ -77,21 +77,23 @@
end
protected
def canonical_path(path)
- #leading and trailing repeated slashes are collapsed, but not ones that appear elsewhere
- path = path.gsub(%r{\A/+},'/').gsub(%r{/+\z},'/')
- components = path.split('/',-1)
- path = components.inject([]) do |acc, component|
- case component
- when '.' #canonicalize by removing .
- when '..' then acc.pop#canonicalize by reducing ..
- else
- acc << component
- end
- acc
- end.join('/')
+ unless @service == 's3' #S3 implements signature v4 different - paths are not canonialized
+ #leading and trailing repeated slashes are collapsed, but not ones that appear elsewhere
+ path = path.gsub(%r{\A/+},'/').gsub(%r{/+\z},'/')
+ components = path.split('/',-1)
+ path = components.inject([]) do |acc, component|
+ case component
+ when '.' #canonicalize by removing .
+ when '..' then acc.pop#canonicalize by reducing ..
+ else
+ acc << component
+ end
+ acc
+ end.join('/')
+ end
path.empty? ? '/' : path
end
def canonical_query_string(query)
canonical_query_string = []