# File lib/fog/aws/signaturev4.rb, line 83 def canonical_path(path) 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