Merge pull request #39861 from vinistock/faster_normalize_path

Switch regex for delete_suffix in normalize_path
This commit is contained in:
Eugene Kenny 2020-07-16 23:33:28 +01:00 committed by GitHub
commit 9b029331b8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -19,11 +19,13 @@ def self.normalize_path(path)
encoding = path.encoding
path = +"/#{path}"
path.squeeze!("/")
path.sub!(%r{/+\Z}, "")
path.gsub!(/(%[a-f0-9]{2})/) { $1.upcase }
path = +"/" if path == ""
unless path == "/"
path.delete_suffix!("/")
path.gsub!(/(%[a-f0-9]{2})/) { $1.upcase }
end
path.force_encoding(encoding)
path
end
# URI path and fragment escaping