lib/postrank-uri.rb in postrank-uri-1.0.23 vs lib/postrank-uri.rb in postrank-uri-1.0.24
- old
+ new
@@ -87,10 +87,11 @@
}iox;
URIREGEX[:reserved_characters] = /%3F|%26/i
URIREGEX[:escape] = /([^ a-zA-Z0-9_.-]+)/x
URIREGEX[:unescape] = /(%[0-9a-fA-F]{2})/x
+ URIREGEX[:double_slash_outside_scheme] = /(?<!http:|https:)\/{2}/x
URIREGEX.each_pair{|k,v| v.freeze }
module_function
def extract(text)
@@ -150,10 +151,10 @@
Digest::MD5.hexdigest(opts[:clean] == true ? clean(uri) : uri)
end
def normalize(uri, opts = {})
u = parse(uri, opts)
- u.path = u.path.squeeze('/')
+ u.path = u.path.gsub(URIREGEX[:double_slash_outside_scheme], '/')
u.path = u.path.chomp('/') if u.path.size != 1
u.query = nil if u.query && u.query.empty?
u.fragment = nil
u
end