uri-whatwg_parser 0.1.1 → 0.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/uri/whatwg_parser/host_parser.rb +14 -1
- data/lib/uri/whatwg_parser/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 57eb48896a4f467a9b2f4d5a9b195a8df8a3b1f707d680711e777b1226d5471a
|
4
|
+
data.tar.gz: 90e1c4a439d6309ac14c7f8e46ace4128c8f8469d275e29b9afa06b60d1e8ac9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: dd95276e9e4df35db76eb196c46b72f1300d777c45161dcf58d3253e477db846d7662cd9f0e837fcc37a3ddd047700c024ecc5c1adeed83c24a478026b188936
|
7
|
+
data.tar.gz: 3cb8ee2b663bb4938bd099106874bed736aa709a38ff4b435803c8ff1752f229a4d8cd83ffb920fc1e29f5ebfc1815f5796105a6f54bb99d241f4b5adb605efa
|
@@ -70,11 +70,24 @@ class URI::WhatwgParser
|
|
70
70
|
addr = IPAddr.new(host)
|
71
71
|
# NOTE: URL Standard doesn't support `zone_id`.
|
72
72
|
raise ParseError, "invalid IPv6 format" unless addr.zone_id.nil?
|
73
|
-
"
|
73
|
+
formatted_addr = (("%.32x" % addr).gsub(/.{4}(?!$)/, '\&:'))
|
74
|
+
"[#{compress_ipv6(formatted_addr)}]"
|
74
75
|
rescue IPAddr::InvalidAddressError
|
75
76
|
raise ParseError, "invalid IPv6 format"
|
76
77
|
end
|
77
78
|
|
79
|
+
def compress_ipv6(ip)
|
80
|
+
output = ip.split(":").map { |term| term.sub(/\A0+/, "").empty? ? "0" : term.sub(/\A0+/, "") }.join(":")
|
81
|
+
zeros = output.scan(/:?(?:0+:?){2,}/)
|
82
|
+
|
83
|
+
unless zeros.empty?
|
84
|
+
max = zeros.max_by { |item| item.gsub(":", "").length }
|
85
|
+
output = output.sub(max, "::")
|
86
|
+
end
|
87
|
+
|
88
|
+
output
|
89
|
+
end
|
90
|
+
|
78
91
|
def parse_opaque_host(host)
|
79
92
|
raise ParseError if include_forbidden_host_code_point?(host)
|
80
93
|
host.chars.map { |c| percent_encode(c, C0_CONTROL_PERCENT_ENCODE_SET) }.join
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: uri-whatwg_parser
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Yuji Yaginuma
|
8
8
|
bindir: exe
|
9
9
|
cert_chain: []
|
10
|
-
date: 2025-05-
|
10
|
+
date: 2025-05-12 00:00:00.000000000 Z
|
11
11
|
dependencies:
|
12
12
|
- !ruby/object:Gem::Dependency
|
13
13
|
name: strscan
|