protocol-url 0.16.0 → 0.18.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 +5 -3
- data/lib/protocol/url/reference.rb +3 -2
- data/lib/protocol/url/relative.rb +18 -4
- data/lib/protocol/url/version.rb +1 -1
- data/readme.md +80 -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: '049540a7791381da861b94d6ed8e6b3e0ad751d3b176106f1c50a029aba36e32'
|
|
4
|
+
data.tar.gz: d6431de11836accc4318f01066b3c2431b9f26e349b46e77fcf9108da80cfb5e
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 27cee8571add43c57a7b0c2255d7f6a40566d1b44fe49b8ed73a7b06c50ef2d9d259eb951c0ffae7bce3c77f026fb193924f7eb003c85bfc61250661c2ed6135
|
|
7
|
+
data.tar.gz: ec74d61c74a06b318b9ff1b9ebcedb261bb90e0f80293b8def6e8d22efeef30db04ebc873e5546f746556312cd45cbeaa6c487893021c0b773a27990a3efd3d5
|
checksums.yaml.gz.sig
CHANGED
|
Binary file
|
|
@@ -114,7 +114,8 @@ module Protocol
|
|
|
114
114
|
end
|
|
115
115
|
|
|
116
116
|
# Append the absolute URL to the given buffer.
|
|
117
|
-
|
|
117
|
+
# @parameter explicit [Boolean] Ignored because absolute URLs are already lexically identifiable.
|
|
118
|
+
def append(buffer = String.new, explicit: false)
|
|
118
119
|
buffer << @scheme << ":" if @scheme
|
|
119
120
|
buffer << "//" << @authority if @authority
|
|
120
121
|
super(buffer)
|
|
@@ -169,9 +170,10 @@ module Protocol
|
|
|
169
170
|
|
|
170
171
|
# Convert the URL to its string representation.
|
|
171
172
|
#
|
|
173
|
+
# @parameter explicit [Boolean] Ignored because absolute URLs are already lexically identifiable.
|
|
172
174
|
# @returns [String] The formatted absolute URL string.
|
|
173
|
-
def to_s
|
|
174
|
-
append
|
|
175
|
+
def to_s(explicit: false)
|
|
176
|
+
append(explicit: explicit)
|
|
175
177
|
end
|
|
176
178
|
end
|
|
177
179
|
end
|
|
@@ -162,8 +162,9 @@ module Protocol
|
|
|
162
162
|
# Append the reference to the given buffer.
|
|
163
163
|
# Encodes the fragment; the path already retains its encoded structure.
|
|
164
164
|
# Query strings are passed through as-is (they contain = and & which are valid syntax).
|
|
165
|
-
|
|
166
|
-
|
|
165
|
+
# @parameter explicit [Boolean] Whether the result should be lexically identifiable as a URL in a mixed grammar.
|
|
166
|
+
def append(buffer = String.new, explicit: false)
|
|
167
|
+
append_path(buffer, explicit: explicit)
|
|
167
168
|
|
|
168
169
|
if @query and !@query.empty?
|
|
169
170
|
buffer << "?" << @query
|
|
@@ -175,8 +175,9 @@ module Protocol
|
|
|
175
175
|
|
|
176
176
|
# Append the relative URL to the given buffer.
|
|
177
177
|
# The path, query, and fragment are expected to already be properly encoded.
|
|
178
|
-
|
|
179
|
-
|
|
178
|
+
# @parameter explicit [Boolean] Whether the result should be lexically identifiable as a URL in a mixed grammar.
|
|
179
|
+
def append(buffer = String.new, explicit: false)
|
|
180
|
+
append_path(buffer, explicit: explicit)
|
|
180
181
|
|
|
181
182
|
if @query and !@query.empty?
|
|
182
183
|
buffer << "?" << @query
|
|
@@ -236,10 +237,13 @@ module Protocol
|
|
|
236
237
|
end
|
|
237
238
|
|
|
238
239
|
# Convert the URL to its string representation.
|
|
240
|
+
# When explicit, same-directory references start with `./` so they can be
|
|
241
|
+
# distinguished from non-URL values in a mixed grammar.
|
|
239
242
|
#
|
|
243
|
+
# @parameter explicit [Boolean] Whether the result should be lexically identifiable as a URL in a mixed grammar.
|
|
240
244
|
# @returns [String] The formatted URL string.
|
|
241
|
-
def to_s
|
|
242
|
-
append
|
|
245
|
+
def to_s(explicit: false)
|
|
246
|
+
append(explicit: explicit)
|
|
243
247
|
end
|
|
244
248
|
|
|
245
249
|
# Convert the URL to a JSON-compatible representation.
|
|
@@ -263,6 +267,16 @@ module Protocol
|
|
|
263
267
|
"#<#{self.class} #{to_s}>"
|
|
264
268
|
end
|
|
265
269
|
|
|
270
|
+
# Append the path, optionally identifying a relative URL explicitly.
|
|
271
|
+
private def append_path(buffer, explicit: false)
|
|
272
|
+
if explicit && @path.relative?
|
|
273
|
+
path = @path.encoded
|
|
274
|
+
buffer << "./" unless path.start_with?("./", "../")
|
|
275
|
+
end
|
|
276
|
+
|
|
277
|
+
buffer << @path.encoded
|
|
278
|
+
end
|
|
279
|
+
|
|
266
280
|
end
|
|
267
281
|
end
|
|
268
282
|
end
|
data/lib/protocol/url/version.rb
CHANGED
data/readme.md
CHANGED
|
@@ -34,6 +34,86 @@ 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.18.0
|
|
38
|
+
|
|
39
|
+
- Support explicit URL serialization for mixed grammars, and remove explicit prefixes from relative path calculation.
|
|
40
|
+
|
|
41
|
+
### v0.17.0
|
|
42
|
+
|
|
43
|
+
- Add optional explicit `./` prefixes when generating same-directory relative URLs.
|
|
44
|
+
|
|
45
|
+
### v0.16.0
|
|
46
|
+
|
|
47
|
+
- Preserve directory and file semantics when generating relative URL paths.
|
|
48
|
+
|
|
49
|
+
### v0.15.0
|
|
50
|
+
|
|
51
|
+
- Add `Protocol::URL::Relative#relative_to` for expressing root-relative URLs relative to a base path.
|
|
52
|
+
|
|
53
|
+
### v0.14.0
|
|
54
|
+
|
|
55
|
+
- Allow paths to compare with their encoded string representation.
|
|
56
|
+
|
|
57
|
+
### v0.13.0
|
|
58
|
+
|
|
59
|
+
- Add conservative normalization of encoded URL paths.
|
|
60
|
+
|
|
61
|
+
### v0.12.0
|
|
62
|
+
|
|
63
|
+
- Allow unfrozen relative and absolute URLs to replace their components.
|
|
64
|
+
|
|
65
|
+
### v0.10.0
|
|
66
|
+
|
|
67
|
+
- Rename `Protocol::URL::FormData::Parser::CONTENT_TYPE` to `MEDIA_TYPE`.
|
|
68
|
+
|
|
69
|
+
### v0.9.0
|
|
70
|
+
|
|
71
|
+
- Add `Protocol::URL::LimitError` for configured processing limits.
|
|
72
|
+
|
|
73
|
+
### v0.8.0
|
|
74
|
+
|
|
75
|
+
- Use consistent limit naming for form data parser constraints.
|
|
76
|
+
|
|
77
|
+
### v0.17.0
|
|
78
|
+
|
|
79
|
+
- Add optional explicit `./` prefixes when generating same-directory relative URLs.
|
|
80
|
+
|
|
81
|
+
### v0.16.0
|
|
82
|
+
|
|
83
|
+
- Preserve directory and file semantics when generating relative URL paths.
|
|
84
|
+
|
|
85
|
+
### v0.15.0
|
|
86
|
+
|
|
87
|
+
- Add `Protocol::URL::Relative#relative_to` for expressing root-relative URLs relative to a base path.
|
|
88
|
+
|
|
89
|
+
### v0.14.0
|
|
90
|
+
|
|
91
|
+
- Allow paths to compare with their encoded string representation.
|
|
92
|
+
|
|
93
|
+
### v0.13.0
|
|
94
|
+
|
|
95
|
+
- Add conservative normalization of encoded URL paths.
|
|
96
|
+
|
|
97
|
+
### v0.12.0
|
|
98
|
+
|
|
99
|
+
- Allow unfrozen relative and absolute URLs to replace their components.
|
|
100
|
+
|
|
101
|
+
### v0.10.0
|
|
102
|
+
|
|
103
|
+
- Rename `Protocol::URL::FormData::Parser::CONTENT_TYPE` to `MEDIA_TYPE`.
|
|
104
|
+
|
|
105
|
+
### v0.9.0
|
|
106
|
+
|
|
107
|
+
- Add `Protocol::URL::LimitError` for configured processing limits.
|
|
108
|
+
|
|
109
|
+
### v0.8.0
|
|
110
|
+
|
|
111
|
+
- Use consistent limit naming for form data parser constraints.
|
|
112
|
+
|
|
113
|
+
### v0.7.0
|
|
114
|
+
|
|
115
|
+
- Allow `Protocol::URL::FormData::Parser#parse` to populate a supplied result object.
|
|
116
|
+
|
|
37
117
|
### v0.16.0
|
|
38
118
|
|
|
39
119
|
- Preserve directory and file semantics when generating relative URL paths.
|
data/releases.md
CHANGED
|
@@ -1,5 +1,13 @@
|
|
|
1
1
|
# Releases
|
|
2
2
|
|
|
3
|
+
## v0.18.0
|
|
4
|
+
|
|
5
|
+
- Support explicit URL serialization for mixed grammars, and remove explicit prefixes from relative path calculation.
|
|
6
|
+
|
|
7
|
+
## v0.17.0
|
|
8
|
+
|
|
9
|
+
- Add optional explicit `./` prefixes when generating same-directory relative URLs.
|
|
10
|
+
|
|
3
11
|
## v0.16.0
|
|
4
12
|
|
|
5
13
|
- Preserve directory and file semantics when generating relative URL paths.
|
data.tar.gz.sig
CHANGED
|
Binary file
|
metadata
CHANGED
metadata.gz.sig
CHANGED
|
Binary file
|