protocol-url 0.13.0 → 0.15.0
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
- checksums.yaml.gz.sig +0 -0
- data/lib/protocol/url/absolute.rb +7 -0
- data/lib/protocol/url/path.rb +7 -3
- data/lib/protocol/url/relative.rb +17 -0
- data/lib/protocol/url/version.rb +1 -1
- data/readme.md +90 -0
- data/releases.md +8 -0
- data.tar.gz.sig +0 -0
- metadata +1 -1
- metadata.gz.sig +0 -0
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 1d1384cd7ea74826bb5dc6e145fb09c9573c807fdac7d2297164317b6caf5645
|
|
4
|
+
data.tar.gz: 4d4b5100c8aca8008c3be18ad9f4b79139c00251f711283a90432179e292c941
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: f284536c31a02466b10821c12bb1a4529a023d789cafbdfae10dd71d8f3049d78f0a0dbc03f8255f3ebdb0b7278eeccd38ca81baf480e116b6fe2a4b72a0bf22
|
|
7
|
+
data.tar.gz: 4ae5bb2749190910c76193b6c451b47b4bbcacaded41002cc54713dc219638e4966f4522f9df2e20a7f04e1e89ab2c09c6df1497bf849afe9a202fb7ad5ceacf
|
checksums.yaml.gz.sig
CHANGED
|
Binary file
|
|
@@ -145,6 +145,13 @@ module Protocol
|
|
|
145
145
|
self.class.new(scheme, authority, path || @path, query, fragment)
|
|
146
146
|
end
|
|
147
147
|
|
|
148
|
+
# Absolute URLs cannot be made relative without comparing their origins.
|
|
149
|
+
# @parameter base [Object] The ignored base URL or path.
|
|
150
|
+
# @returns [self] This absolute URL.
|
|
151
|
+
def relative_to(base)
|
|
152
|
+
return self
|
|
153
|
+
end
|
|
154
|
+
|
|
148
155
|
# Convert the URL to an array representation.
|
|
149
156
|
#
|
|
150
157
|
# @returns [Array] An array of `[scheme, authority, path, query, fragment]`.
|
data/lib/protocol/url/path.rb
CHANGED
|
@@ -208,14 +208,18 @@ module Protocol
|
|
|
208
208
|
end
|
|
209
209
|
|
|
210
210
|
# @parameter other [Object] The value to compare with this path.
|
|
211
|
-
# @returns [Boolean] Whether both
|
|
211
|
+
# @returns [Boolean] Whether both values are the same.
|
|
212
212
|
def ==(other)
|
|
213
|
-
|
|
213
|
+
if other.is_a?(String)
|
|
214
|
+
return encoded == other
|
|
215
|
+
else
|
|
216
|
+
return eql?(other)
|
|
217
|
+
end
|
|
214
218
|
end
|
|
215
219
|
|
|
216
220
|
# Compare this path with another path using exact encoded string identity.
|
|
217
221
|
# @parameter other [Object] The value to compare with this path.
|
|
218
|
-
# @returns [Boolean] Whether both paths
|
|
222
|
+
# @returns [Boolean] Whether both paths are the same.
|
|
219
223
|
def eql?(other)
|
|
220
224
|
other.is_a?(Path) && encoded.eql?(other.encoded)
|
|
221
225
|
end
|
|
@@ -132,6 +132,23 @@ module Protocol
|
|
|
132
132
|
self.class.new(path || @path, query, fragment)
|
|
133
133
|
end
|
|
134
134
|
|
|
135
|
+
# Express this URL relative to the given base path.
|
|
136
|
+
#
|
|
137
|
+
# Already-relative paths are returned unchanged. Query and fragment components
|
|
138
|
+
# are preserved when converting a root-relative path.
|
|
139
|
+
#
|
|
140
|
+
# @parameter base [Relative | Path | String] The base URL or path.
|
|
141
|
+
# @returns [Relative] The relative URL.
|
|
142
|
+
def relative_to(base)
|
|
143
|
+
return self unless @path.absolute?
|
|
144
|
+
|
|
145
|
+
if base.is_a?(Relative)
|
|
146
|
+
base = base.path
|
|
147
|
+
end
|
|
148
|
+
|
|
149
|
+
return self.class.new(@path.relative(base), @query, @fragment)
|
|
150
|
+
end
|
|
151
|
+
|
|
135
152
|
# Normalize the encoded path and simplify its structure.
|
|
136
153
|
#
|
|
137
154
|
# This modifies the URL in-place by normalizing and simplifying the path component:
|
data/lib/protocol/url/version.rb
CHANGED
data/readme.md
CHANGED
|
@@ -34,6 +34,96 @@ bundle exec sus
|
|
|
34
34
|
|
|
35
35
|
Please see the [project releases](https://socketry.github.io/protocol-url/releases/index) for all releases.
|
|
36
36
|
|
|
37
|
+
### v0.15.0
|
|
38
|
+
|
|
39
|
+
- Add `Protocol::URL::Relative#relative_to` for expressing root-relative URLs relative to a base path.
|
|
40
|
+
|
|
41
|
+
### v0.14.0
|
|
42
|
+
|
|
43
|
+
- Allow paths to compare with their encoded string representation.
|
|
44
|
+
|
|
45
|
+
### v0.13.0
|
|
46
|
+
|
|
47
|
+
- Add conservative normalization of encoded URL paths.
|
|
48
|
+
|
|
49
|
+
### v0.12.0
|
|
50
|
+
|
|
51
|
+
- Allow unfrozen relative and absolute URLs to replace their components.
|
|
52
|
+
|
|
53
|
+
### v0.10.0
|
|
54
|
+
|
|
55
|
+
- Rename `Protocol::URL::FormData::Parser::CONTENT_TYPE` to `MEDIA_TYPE`.
|
|
56
|
+
|
|
57
|
+
### v0.9.0
|
|
58
|
+
|
|
59
|
+
- Add `Protocol::URL::LimitError` for configured processing limits.
|
|
60
|
+
|
|
61
|
+
### v0.8.0
|
|
62
|
+
|
|
63
|
+
- Use consistent limit naming for form data parser constraints.
|
|
64
|
+
|
|
65
|
+
### v0.7.0
|
|
66
|
+
|
|
67
|
+
- Allow `Protocol::URL::FormData::Parser#parse` to populate a supplied result object.
|
|
68
|
+
|
|
69
|
+
### v0.6.0
|
|
70
|
+
|
|
71
|
+
- Add `Protocol::URL::FormData::Parser` for incremental, limited parsing of `application/x-www-form-urlencoded` form data.
|
|
72
|
+
- Add `Protocol::URL::FormData::Nested` for consistently building nested form data while preserving absent and empty values.
|
|
73
|
+
|
|
74
|
+
### v0.5.0
|
|
75
|
+
|
|
76
|
+
- Add `Protocol::URL::Encoding.decode_www_form` for decoding HTML form data where `+` represents a space.
|
|
77
|
+
|
|
78
|
+
### v0.14.0
|
|
79
|
+
|
|
80
|
+
- Allow paths to compare with their encoded string representation.
|
|
81
|
+
|
|
82
|
+
### v0.13.0
|
|
83
|
+
|
|
84
|
+
- Add conservative normalization of encoded URL paths.
|
|
85
|
+
|
|
86
|
+
### v0.12.0
|
|
87
|
+
|
|
88
|
+
- Allow unfrozen relative and absolute URLs to replace their components.
|
|
89
|
+
|
|
90
|
+
### v0.10.0
|
|
91
|
+
|
|
92
|
+
- Rename `Protocol::URL::FormData::Parser::CONTENT_TYPE` to `MEDIA_TYPE`.
|
|
93
|
+
|
|
94
|
+
### v0.9.0
|
|
95
|
+
|
|
96
|
+
- Add `Protocol::URL::LimitError` for configured processing limits.
|
|
97
|
+
|
|
98
|
+
### v0.8.0
|
|
99
|
+
|
|
100
|
+
- Use consistent limit naming for form data parser constraints.
|
|
101
|
+
|
|
102
|
+
### v0.7.0
|
|
103
|
+
|
|
104
|
+
- Allow `Protocol::URL::FormData::Parser#parse` to populate a supplied result object.
|
|
105
|
+
|
|
106
|
+
### v0.6.0
|
|
107
|
+
|
|
108
|
+
- Add `Protocol::URL::FormData::Parser` for incremental, limited parsing of `application/x-www-form-urlencoded` form data.
|
|
109
|
+
- Add `Protocol::URL::FormData::Nested` for consistently building nested form data while preserving absent and empty values.
|
|
110
|
+
|
|
111
|
+
### v0.5.0
|
|
112
|
+
|
|
113
|
+
- Add `Protocol::URL::Encoding.decode_www_form` for decoding HTML form data where `+` represents a space.
|
|
114
|
+
|
|
115
|
+
### v0.4.0
|
|
116
|
+
|
|
117
|
+
- Add comparison methods to `Protocol::URL::Relative` (and by inheritance to `Protocol::URL::Absolute`):
|
|
118
|
+
- `#==` for structural equality comparison (compares path, query, fragment components).
|
|
119
|
+
- `#===` for string equality comparison (enables case statement matching).
|
|
120
|
+
- `#<=>` for ordering and sorting.
|
|
121
|
+
- `#hash` for hash key support.
|
|
122
|
+
- `#equal?` for component-based equality checking.
|
|
123
|
+
- Add JSON serialization support to `Protocol::URL::Relative`:
|
|
124
|
+
- `#as_json` returns the string representation.
|
|
125
|
+
- `#to_json` returns a JSON-encoded string.
|
|
126
|
+
|
|
37
127
|
### v0.13.0
|
|
38
128
|
|
|
39
129
|
- Add conservative normalization of encoded URL paths.
|
data/releases.md
CHANGED
|
@@ -1,5 +1,13 @@
|
|
|
1
1
|
# Releases
|
|
2
2
|
|
|
3
|
+
## v0.15.0
|
|
4
|
+
|
|
5
|
+
- Add `Protocol::URL::Relative#relative_to` for expressing root-relative URLs relative to a base path.
|
|
6
|
+
|
|
7
|
+
## v0.14.0
|
|
8
|
+
|
|
9
|
+
- Allow paths to compare with their encoded string representation.
|
|
10
|
+
|
|
3
11
|
## v0.13.0
|
|
4
12
|
|
|
5
13
|
- Add conservative normalization of encoded URL paths.
|
data.tar.gz.sig
CHANGED
|
Binary file
|
metadata
CHANGED
metadata.gz.sig
CHANGED
|
Binary file
|