addressable 2.4.0 → 2.9.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 +5 -5
- data/CHANGELOG.md +167 -33
- data/README.md +36 -20
- data/lib/addressable/idna/native.rb +19 -8
- data/lib/addressable/idna/pure.rb +4263 -225
- data/lib/addressable/idna.rb +3 -2
- data/lib/addressable/template.rb +90 -101
- data/lib/addressable/uri.rb +414 -236
- data/lib/addressable/version.rb +4 -3
- data/lib/addressable.rb +2 -0
- metadata +21 -35
- data/Gemfile +0 -27
- data/Rakefile +0 -32
- data/addressable.gemspec +0 -34
- data/data/unicode.data +0 -0
- data/spec/addressable/idna_spec.rb +0 -270
- data/spec/addressable/net_http_compat_spec.rb +0 -28
- data/spec/addressable/rack_mount_compat_spec.rb +0 -104
- data/spec/addressable/security_spec.rb +0 -57
- data/spec/addressable/template_spec.rb +0 -1386
- data/spec/addressable/uri_spec.rb +0 -6205
- data/spec/spec_helper.rb +0 -21
- data/tasks/clobber.rake +0 -2
- data/tasks/gem.rake +0 -97
- data/tasks/git.rake +0 -45
- data/tasks/metrics.rake +0 -22
- data/tasks/rspec.rake +0 -21
- data/tasks/yard.rake +0 -27
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
|
-
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
2
|
+
SHA256:
|
|
3
|
+
metadata.gz: ffaab8b78df30a2126058a425f168d76b26bc33e60849cabc1a6beabae24464d
|
|
4
|
+
data.tar.gz: 841ab2bd18fbcf3ff746cb85ea1661e628e278e6c7bc5ad96cd480e36a54f067
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: f5884313cb2c68ea73d25e8f7f0a76200030bb3fb7abad8b31532180b1ae3c1df10f8db614a273dba115c87860682d227fdf046c743370e020a577cae667d026
|
|
7
|
+
data.tar.gz: c97dd91446991ce20400e9b4c2586aefbc1dca9fd1d49efca9606fc505ff0d49807686ab1fdfd7d4dba447c9c4bf8fb6c0bbd5a1d3d69a4952207d035e912dc2
|
data/CHANGELOG.md
CHANGED
|
@@ -1,4 +1,138 @@
|
|
|
1
|
-
#
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
## Addressable 2.9.0 <a name="v2.9.0">
|
|
4
|
+
- fixes ReDoS vulnerability in Addressable::Template#match (fixes incomplete
|
|
5
|
+
remediation in 2.8.10)
|
|
6
|
+
|
|
7
|
+
## Addressable 2.8.10 <a name="v2.8.10">
|
|
8
|
+
- fixes ReDoS vulnerability in Addressable::Template#match
|
|
9
|
+
|
|
10
|
+
## Addressable 2.8.9 <a name="v2.8.9">
|
|
11
|
+
- Reduce gem size by excluding test files ([#569])
|
|
12
|
+
- No need for bundler as development dependency ([#571], [5fc1d93](https://github.com/sporkmonger/addressable/commit/5fc1d93))
|
|
13
|
+
- idna/pure: stop building the useless `COMPOSITION_TABLE` (removes the `Addressable::IDNA::COMPOSITION_TABLE` constant) ([#564])
|
|
14
|
+
|
|
15
|
+
[#569]: https://github.com/sporkmonger/addressable/pull/569
|
|
16
|
+
[#571]: https://github.com/sporkmonger/addressable/pull/571
|
|
17
|
+
[#564]: https://github.com/sporkmonger/addressable/pull/564
|
|
18
|
+
|
|
19
|
+
## Addressable 2.8.8 <a name="v2.8.8">
|
|
20
|
+
- Replace the `unicode.data` blob by a ruby constant ([#561])
|
|
21
|
+
- Allow `public_suffix` 7 ([#558])
|
|
22
|
+
|
|
23
|
+
[#561]: https://github.com/sporkmonger/addressable/pull/561
|
|
24
|
+
[#558]: https://github.com/sporkmonger/addressable/pull/558
|
|
25
|
+
|
|
26
|
+
## Addressable 2.8.7 <a name="v2.8.7">
|
|
27
|
+
- Allow `public_suffix` 6 ([#535])
|
|
28
|
+
|
|
29
|
+
[#535]: https://github.com/sporkmonger/addressable/pull/535
|
|
30
|
+
|
|
31
|
+
## Addressable 2.8.6 <a name="v2.8.6">
|
|
32
|
+
- Memoize regexps for common character classes ([#524])
|
|
33
|
+
|
|
34
|
+
[#524]: https://github.com/sporkmonger/addressable/pull/524
|
|
35
|
+
|
|
36
|
+
## Addressable 2.8.5 <a name="v2.8.5">
|
|
37
|
+
- Fix thread safety issue with encoding tables ([#515])
|
|
38
|
+
- Define URI::NONE as a module to avoid serialization issues ([#509])
|
|
39
|
+
- Fix YAML serialization ([#508])
|
|
40
|
+
|
|
41
|
+
[#508]: https://github.com/sporkmonger/addressable/pull/508
|
|
42
|
+
[#509]: https://github.com/sporkmonger/addressable/pull/509
|
|
43
|
+
[#515]: https://github.com/sporkmonger/addressable/pull/515
|
|
44
|
+
|
|
45
|
+
## Addressable 2.8.4 <a name="v2.8.4">
|
|
46
|
+
- Restore `Addressable::IDNA.unicode_normalize_kc` as a deprecated method ([#504])
|
|
47
|
+
|
|
48
|
+
[#504]: https://github.com/sporkmonger/addressable/pull/504
|
|
49
|
+
|
|
50
|
+
## Addressable 2.8.3 <a name="v2.8.3">
|
|
51
|
+
- Fix template expand level 2 hash support for non-string objects ([#499], [#498])
|
|
52
|
+
|
|
53
|
+
[#499]: https://github.com/sporkmonger/addressable/pull/499
|
|
54
|
+
[#498]: https://github.com/sporkmonger/addressable/pull/498
|
|
55
|
+
|
|
56
|
+
## Addressable 2.8.2 <a name="v2.8.2">
|
|
57
|
+
- Improve cache hits and JIT friendliness ([#486](https://github.com/sporkmonger/addressable/pull/486))
|
|
58
|
+
- Improve code style and test coverage ([#482](https://github.com/sporkmonger/addressable/pull/482))
|
|
59
|
+
- Ensure reset of deferred validation ([#481](https://github.com/sporkmonger/addressable/pull/481))
|
|
60
|
+
- Resolve normalization differences between `IDNA::Native` and `IDNA::Pure` ([#408](https://github.com/sporkmonger/addressable/issues/408), [#492])
|
|
61
|
+
- Remove redundant colon in `Addressable::URI::CharacterClasses::AUTHORITY` regex ([#438](https://github.com/sporkmonger/addressable/pull/438)) (accidentally reverted by [#449] merge but [added back](https://github.com/sporkmonger/addressable/pull/492#discussion_r1105125280) in [#492])
|
|
62
|
+
|
|
63
|
+
[#492]: https://github.com/sporkmonger/addressable/pull/492
|
|
64
|
+
|
|
65
|
+
## Addressable 2.8.1 <a name="v2.8.1">
|
|
66
|
+
- refactor `Addressable::URI.normalize_path` to address linter offenses ([#430](https://github.com/sporkmonger/addressable/pull/430))
|
|
67
|
+
- update gemspec to reflect supported Ruby versions ([#466], [#464], [#463])
|
|
68
|
+
- compatibility w/ public_suffix 5.x ([#466], [#465], [#460])
|
|
69
|
+
- fixes "invalid byte sequence in UTF-8" exception when unencoding URLs containing non UTF-8 characters ([#459](https://github.com/sporkmonger/addressable/pull/459))
|
|
70
|
+
- `Ractor` compatibility ([#449])
|
|
71
|
+
- use the whole string instead of a single line for template match ([#431](https://github.com/sporkmonger/addressable/pull/431))
|
|
72
|
+
- force UTF-8 encoding only if needed ([#341](https://github.com/sporkmonger/addressable/pull/341))
|
|
73
|
+
|
|
74
|
+
[#449]: https://github.com/sporkmonger/addressable/pull/449
|
|
75
|
+
[#460]: https://github.com/sporkmonger/addressable/pull/460
|
|
76
|
+
[#463]: https://github.com/sporkmonger/addressable/pull/463
|
|
77
|
+
[#464]: https://github.com/sporkmonger/addressable/pull/464
|
|
78
|
+
[#465]: https://github.com/sporkmonger/addressable/pull/465
|
|
79
|
+
[#466]: https://github.com/sporkmonger/addressable/pull/466
|
|
80
|
+
|
|
81
|
+
## Addressable 2.8.0 <a name="v2.8.0">
|
|
82
|
+
- fixes ReDoS vulnerability in Addressable::Template#match
|
|
83
|
+
- no longer replaces `+` with spaces in queries for non-http(s) schemes
|
|
84
|
+
- fixed encoding ipv6 literals
|
|
85
|
+
- the `:compacted` flag for `normalized_query` now dedupes parameters
|
|
86
|
+
- fix broken `escape_component` alias
|
|
87
|
+
- dropping support for Ruby 2.0 and 2.1
|
|
88
|
+
- adding Ruby 3.0 compatibility for development tasks
|
|
89
|
+
- drop support for `rack-mount` and remove Addressable::Template#generate
|
|
90
|
+
- performance improvements
|
|
91
|
+
- switch CI/CD to GitHub Actions
|
|
92
|
+
|
|
93
|
+
## Addressable 2.7.0 <a name="v2.7.0">
|
|
94
|
+
- added `:compacted` flag to `normalized_query`
|
|
95
|
+
- `heuristic_parse` handles `mailto:` more intuitively
|
|
96
|
+
- dropped explicit support for JRuby 9.0.5.0
|
|
97
|
+
- compatibility w/ public_suffix 4.x
|
|
98
|
+
- performance improvements
|
|
99
|
+
|
|
100
|
+
## Addressable 2.6.0 <a name="v2.6.0">
|
|
101
|
+
- added `tld=` method to allow assignment to the public suffix
|
|
102
|
+
- most `heuristic_parse` patterns are now case-insensitive
|
|
103
|
+
- `heuristic_parse` handles more `file://` URI variations
|
|
104
|
+
- fixes bug in `heuristic_parse` when uri starts with digit
|
|
105
|
+
- fixes bug in `request_uri=` with query strings
|
|
106
|
+
- fixes template issues with `nil` and `?` operator
|
|
107
|
+
- `frozen_string_literal` pragmas added
|
|
108
|
+
- minor performance improvements in regexps
|
|
109
|
+
- fixes to eliminate warnings
|
|
110
|
+
|
|
111
|
+
## Addressable 2.5.2 <a name="v2.5.2">
|
|
112
|
+
- better support for frozen string literals
|
|
113
|
+
- fixed bug w/ uppercase characters in scheme
|
|
114
|
+
- IDNA errors w/ emoji URLs
|
|
115
|
+
- compatibility w/ public_suffix 3.x
|
|
116
|
+
|
|
117
|
+
## Addressable 2.5.1 <a name="v2.5.1">
|
|
118
|
+
- allow unicode normalization to be disabled for URI Template expansion
|
|
119
|
+
- removed duplicate test
|
|
120
|
+
|
|
121
|
+
## Addressable 2.5.0 <a name="v2.5.0">
|
|
122
|
+
- dropping support for Ruby 1.9
|
|
123
|
+
- adding support for Ruby 2.4 preview
|
|
124
|
+
- add support for public suffixes and tld; first runtime dependency
|
|
125
|
+
- hostname escaping should match RFC; underscores in hostnames no longer escaped
|
|
126
|
+
- paths beginning with // and missing an authority are now considered invalid
|
|
127
|
+
- validation now also takes place after setting a path
|
|
128
|
+
- handle backslashes in authority more like a browser for `heuristic_parse`
|
|
129
|
+
- unescaped backslashes in host now raise an `InvalidURIError`
|
|
130
|
+
- `merge!`, `join!`, `omit!` and `normalize!` don't disable deferred validation
|
|
131
|
+
- `heuristic_parse` now trims whitespace before parsing
|
|
132
|
+
- host parts longer than 63 bytes will be ignored and not passed to libidn
|
|
133
|
+
- normalized values always encoded as UTF-8
|
|
134
|
+
|
|
135
|
+
## Addressable 2.4.0 <a name="v2.4.0">
|
|
2
136
|
- support for 1.8.x dropped
|
|
3
137
|
- double quotes in a host now raises an error
|
|
4
138
|
- newlines in host will no longer get unescaped during normalization
|
|
@@ -10,17 +144,17 @@
|
|
|
10
144
|
- fixed minor bug where an exception would be thrown for a missing ACE suffix
|
|
11
145
|
- better partial expansion of URI templates
|
|
12
146
|
|
|
13
|
-
|
|
147
|
+
## Addressable 2.3.8 <a name="v2.3.8">
|
|
14
148
|
- fix warnings
|
|
15
149
|
- update dependency gems
|
|
16
150
|
- support for 1.8.x officially deprecated
|
|
17
151
|
|
|
18
|
-
|
|
152
|
+
## Addressable 2.3.7 <a name="v2.3.7">
|
|
19
153
|
- fix scenario in which invalid URIs don't get an exception until inspected
|
|
20
154
|
- handle hostnames with two adjacent periods correctly
|
|
21
155
|
- upgrade of RSpec
|
|
22
156
|
|
|
23
|
-
|
|
157
|
+
## Addressable 2.3.6 <a name="v2.3.6">
|
|
24
158
|
- normalization drops empty query string
|
|
25
159
|
- better handling in template extract for missing values
|
|
26
160
|
- template modifier for `'?'` now treated as optional
|
|
@@ -29,19 +163,19 @@
|
|
|
29
163
|
- added `:sorted` option to normalization of query strings
|
|
30
164
|
- fixed issue with normalization of hosts given in `'example.com.'` form
|
|
31
165
|
|
|
32
|
-
|
|
166
|
+
## Addressable 2.3.5 <a name="v2.3.5">
|
|
33
167
|
- added Addressable::URI#empty? method
|
|
34
168
|
- Addressable::URI#hostname methods now strip square brackets from IPv6 hosts
|
|
35
169
|
- compatibility with Net::HTTP in Ruby 2.0.0
|
|
36
170
|
- Addressable::URI#route_from should always give relative URIs
|
|
37
171
|
|
|
38
|
-
|
|
172
|
+
## Addressable 2.3.4 <a name="v2.3.4">
|
|
39
173
|
- fixed issue with encoding altering its inputs
|
|
40
174
|
- query string normalization now leaves ';' characters alone
|
|
41
175
|
- FakeFS is detected before attempting to load unicode tables
|
|
42
176
|
- additional testing to ensure frozen objects don't cause problems
|
|
43
177
|
|
|
44
|
-
|
|
178
|
+
## Addressable 2.3.3 <a name="v2.3.3">
|
|
45
179
|
- fixed issue with converting common primitives during template expansion
|
|
46
180
|
- fixed port encoding issue
|
|
47
181
|
- removed a few warnings
|
|
@@ -50,59 +184,59 @@
|
|
|
50
184
|
- no template match should now result in nil instead of an empty MatchData
|
|
51
185
|
- added license information to gemspec
|
|
52
186
|
|
|
53
|
-
|
|
187
|
+
## Addressable 2.3.2 <a name="v2.3.2">
|
|
54
188
|
- added Addressable::URI#default_port method
|
|
55
189
|
- fixed issue with Marshalling Unicode data on Windows
|
|
56
190
|
- improved heuristic parsing to better handle IPv4 addresses
|
|
57
191
|
|
|
58
|
-
|
|
192
|
+
## Addressable 2.3.1 <a name="v2.3.1">
|
|
59
193
|
- fixed missing unicode data file
|
|
60
194
|
|
|
61
|
-
|
|
195
|
+
## Addressable 2.3.0 <a name="v2.3.0">
|
|
62
196
|
- updated Addressable::Template to use RFC 6570, level 4
|
|
63
197
|
- fixed compatibility problems with some versions of Ruby
|
|
64
198
|
- moved unicode tables into a data file for performance reasons
|
|
65
199
|
- removing support for multiple query value notations
|
|
66
200
|
|
|
67
|
-
|
|
201
|
+
## Addressable 2.2.8 <a name="v2.2.8">
|
|
68
202
|
- fixed issues with dot segment removal code
|
|
69
203
|
- form encoding can now handle multiple values per key
|
|
70
204
|
- updated development environment
|
|
71
205
|
|
|
72
|
-
|
|
206
|
+
## Addressable 2.2.7 <a name="v2.2.7">
|
|
73
207
|
- fixed issues related to Addressable::URI#query_values=
|
|
74
208
|
- the Addressable::URI.parse method is now polymorphic
|
|
75
209
|
|
|
76
|
-
|
|
210
|
+
## Addressable 2.2.6 <a name="v2.2.6">
|
|
77
211
|
- changed the way ambiguous paths are handled
|
|
78
212
|
- fixed bug with frozen URIs
|
|
79
213
|
- https supported in heuristic parsing
|
|
80
214
|
|
|
81
|
-
|
|
215
|
+
## Addressable 2.2.5 <a name="v2.2.5">
|
|
82
216
|
- 'parsing' a pre-parsed URI object is now a dup operation
|
|
83
217
|
- introduced conditional support for libidn
|
|
84
218
|
- fixed normalization issue on ampersands in query strings
|
|
85
219
|
- added additional tests around handling of query strings
|
|
86
220
|
|
|
87
|
-
|
|
221
|
+
## Addressable 2.2.4 <a name="v2.2.4">
|
|
88
222
|
- added origin support from draft-ietf-websec-origin-00
|
|
89
223
|
- resolved issue with attempting to navigate below root
|
|
90
224
|
- fixed bug with string splitting in query strings
|
|
91
225
|
|
|
92
|
-
|
|
226
|
+
## Addressable 2.2.3 <a name="v2.2.3">
|
|
93
227
|
- added :flat_array notation for query strings
|
|
94
228
|
|
|
95
|
-
|
|
229
|
+
## Addressable 2.2.2 <a name="v2.2.2">
|
|
96
230
|
- fixed issue with percent escaping of '+' character in query strings
|
|
97
231
|
|
|
98
|
-
|
|
232
|
+
## Addressable 2.2.1 <a name="v2.2.1">
|
|
99
233
|
- added support for application/x-www-form-urlencoded.
|
|
100
234
|
|
|
101
|
-
|
|
235
|
+
## Addressable 2.2.0 <a name="v2.2.0">
|
|
102
236
|
- added site methods
|
|
103
237
|
- improved documentation
|
|
104
238
|
|
|
105
|
-
|
|
239
|
+
## Addressable 2.1.2 <a name="v2.1.2">
|
|
106
240
|
- added HTTP request URI methods
|
|
107
241
|
- better handling of Windows file paths
|
|
108
242
|
- validation_deferred boolean replaced with defer_validation block
|
|
@@ -110,14 +244,14 @@
|
|
|
110
244
|
- fixed issue with constructing URIs with relative paths
|
|
111
245
|
- fixed warnings
|
|
112
246
|
|
|
113
|
-
|
|
247
|
+
## Addressable 2.1.1 <a name="v2.1.1">
|
|
114
248
|
- more type checking changes
|
|
115
249
|
- fixed issue with unicode normalization
|
|
116
250
|
- added method to find template defaults
|
|
117
251
|
- symbolic keys are now allowed in template mappings
|
|
118
252
|
- numeric values and symbolic values are now allowed in template mappings
|
|
119
253
|
|
|
120
|
-
|
|
254
|
+
## Addressable 2.1.0 <a name="v2.1.0x">
|
|
121
255
|
- refactored URI template support out into its own class
|
|
122
256
|
- removed extract method due to being useless and unreliable
|
|
123
257
|
- removed Addressable::URI.expand_template
|
|
@@ -131,15 +265,15 @@
|
|
|
131
265
|
- worked around issue with freezing URIs
|
|
132
266
|
- improved specs
|
|
133
267
|
|
|
134
|
-
|
|
268
|
+
## Addressable 2.0.2 <a name="v2.0.2">
|
|
135
269
|
- fixed issue with URI template expansion
|
|
136
270
|
- fixed issue with percent escaping characters 0-15
|
|
137
271
|
|
|
138
|
-
|
|
272
|
+
## Addressable 2.0.1 <a name="v2.0.1">
|
|
139
273
|
- fixed issue with query string assignment
|
|
140
274
|
- fixed issue with improperly encoded components
|
|
141
275
|
|
|
142
|
-
|
|
276
|
+
## Addressable 2.0.0 <a name="v2.0.0">
|
|
143
277
|
- the initialize method now takes an options hash as its only parameter
|
|
144
278
|
- added query_values method to URI class
|
|
145
279
|
- completely replaced IDNA implementation with pure Ruby
|
|
@@ -154,20 +288,20 @@
|
|
|
154
288
|
- updated URI Template code to match v 03 of the draft spec
|
|
155
289
|
- added a bunch of new specifications
|
|
156
290
|
|
|
157
|
-
|
|
291
|
+
## Addressable 1.0.4 <a name="v1.0.4">
|
|
158
292
|
- switched to using RSpec's pending system for specs that rely on IDN
|
|
159
293
|
- fixed issue with creating URIs with paths that are not prefixed with '/'
|
|
160
294
|
|
|
161
|
-
|
|
295
|
+
## Addressable 1.0.3 <a name="v1.0.3">
|
|
162
296
|
- implemented a hash method
|
|
163
297
|
|
|
164
|
-
|
|
298
|
+
## Addressable 1.0.2 <a name="v1.0.2">
|
|
165
299
|
- fixed minor bug with the extract_mapping method
|
|
166
300
|
|
|
167
|
-
|
|
301
|
+
## Addressable 1.0.1 <a name="v1.0.1">
|
|
168
302
|
- fixed minor bug with the extract_mapping method
|
|
169
303
|
|
|
170
|
-
|
|
304
|
+
## Addressable 1.0.0 <a name="v1.0.0">
|
|
171
305
|
- heuristic parse method added
|
|
172
306
|
- parsing is slightly more strict
|
|
173
307
|
- replaced to_h with to_hash
|
|
@@ -176,16 +310,16 @@
|
|
|
176
310
|
- improved heckle rake task
|
|
177
311
|
- no surviving heckle mutations
|
|
178
312
|
|
|
179
|
-
|
|
313
|
+
## Addressable 0.1.2 <a name="v0.1.2">
|
|
180
314
|
- improved normalization
|
|
181
315
|
- fixed bug in joining algorithm
|
|
182
316
|
- updated specifications
|
|
183
317
|
|
|
184
|
-
|
|
318
|
+
## Addressable 0.1.1 <a name="v0.1.1">
|
|
185
319
|
- updated documentation
|
|
186
320
|
- added URI Template variable extraction
|
|
187
321
|
|
|
188
|
-
|
|
322
|
+
## Addressable 0.1.0 <a name="v0.1.0">
|
|
189
323
|
- initial release
|
|
190
324
|
- implementation based on RFC 3986, 3987
|
|
191
325
|
- support for IRIs via libidn
|
data/README.md
CHANGED
|
@@ -3,35 +3,34 @@
|
|
|
3
3
|
<dl>
|
|
4
4
|
<dt>Homepage</dt><dd><a href="https://github.com/sporkmonger/addressable">github.com/sporkmonger/addressable</a></dd>
|
|
5
5
|
<dt>Author</dt><dd><a href="mailto:bob@sporkmonger.com">Bob Aman</a></dd>
|
|
6
|
-
<dt>Copyright</dt><dd>Copyright ©
|
|
6
|
+
<dt>Copyright</dt><dd>Copyright © Bob Aman</dd>
|
|
7
7
|
<dt>License</dt><dd>Apache 2.0</dd>
|
|
8
8
|
</dl>
|
|
9
9
|
|
|
10
|
-
[][gemnasium]
|
|
10
|
+
[][gem]
|
|
11
|
+
[][actions]
|
|
13
12
|
[][coveralls]
|
|
14
|
-
[](https://www.gittip.com/sporkmonger/ "Support Open Source Development w/ Gittip")
|
|
13
|
+
[][inch]
|
|
16
14
|
|
|
17
15
|
[gem]: https://rubygems.org/gems/addressable
|
|
18
|
-
[
|
|
19
|
-
[gemnasium]: https://gemnasium.com/sporkmonger/addressable
|
|
16
|
+
[actions]: https://github.com/sporkmonger/addressable/actions
|
|
20
17
|
[coveralls]: https://coveralls.io/r/sporkmonger/addressable
|
|
21
|
-
[inch]:
|
|
18
|
+
[inch]: https://inch-ci.org/github/sporkmonger/addressable
|
|
22
19
|
|
|
23
|
-
|
|
20
|
+
## Description
|
|
24
21
|
|
|
25
|
-
Addressable is
|
|
26
|
-
Ruby's standard library. It
|
|
27
|
-
|
|
22
|
+
Addressable is an alternative implementation to the URI implementation
|
|
23
|
+
that is part of Ruby's standard library. It is flexible, offers heuristic
|
|
24
|
+
parsing, and additionally provides extensive support for IRIs and URI templates.
|
|
28
25
|
|
|
29
|
-
|
|
26
|
+
Addressable closely conforms to RFC 3986, RFC 3987, and RFC 6570 (level 4).
|
|
27
|
+
|
|
28
|
+
## Reference
|
|
30
29
|
|
|
31
30
|
- {Addressable::URI}
|
|
32
31
|
- {Addressable::Template}
|
|
33
32
|
|
|
34
|
-
|
|
33
|
+
## Example usage
|
|
35
34
|
|
|
36
35
|
```ruby
|
|
37
36
|
require "addressable/uri"
|
|
@@ -50,7 +49,7 @@ uri.normalize
|
|
|
50
49
|
```
|
|
51
50
|
|
|
52
51
|
|
|
53
|
-
|
|
52
|
+
## URI Templates
|
|
54
53
|
|
|
55
54
|
For more details, see [RFC 6570](https://www.rfc-editor.org/rfc/rfc6570.txt).
|
|
56
55
|
|
|
@@ -59,7 +58,7 @@ For more details, see [RFC 6570](https://www.rfc-editor.org/rfc/rfc6570.txt).
|
|
|
59
58
|
|
|
60
59
|
require "addressable/template"
|
|
61
60
|
|
|
62
|
-
template = Addressable::Template.new("http://example.com/{?query*}
|
|
61
|
+
template = Addressable::Template.new("http://example.com/{?query*}")
|
|
63
62
|
template.expand({
|
|
64
63
|
"query" => {
|
|
65
64
|
'foo' => 'bar',
|
|
@@ -89,17 +88,34 @@ template.extract(uri)
|
|
|
89
88
|
# }
|
|
90
89
|
```
|
|
91
90
|
|
|
92
|
-
|
|
91
|
+
## Install
|
|
93
92
|
|
|
94
93
|
```console
|
|
95
|
-
$
|
|
94
|
+
$ gem install addressable
|
|
96
95
|
```
|
|
97
96
|
|
|
98
97
|
You may optionally turn on native IDN support by installing libidn and the
|
|
99
98
|
idn gem:
|
|
100
99
|
|
|
101
100
|
```console
|
|
102
|
-
$ sudo apt-get install
|
|
101
|
+
$ sudo apt-get install libidn11-dev # Debian/Ubuntu
|
|
103
102
|
$ brew install libidn # OS X
|
|
104
103
|
$ gem install idn-ruby
|
|
105
104
|
```
|
|
105
|
+
|
|
106
|
+
## Semantic Versioning
|
|
107
|
+
|
|
108
|
+
This project uses [Semantic Versioning](https://semver.org/). You can (and should) specify your
|
|
109
|
+
dependency using a pessimistic version constraint covering the major and minor
|
|
110
|
+
values:
|
|
111
|
+
|
|
112
|
+
```ruby
|
|
113
|
+
spec.add_dependency 'addressable', '~> 2.7'
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
If you need a specific bug fix, you can also specify minimum tiny versions
|
|
117
|
+
without preventing updates to the latest minor release:
|
|
118
|
+
|
|
119
|
+
```ruby
|
|
120
|
+
spec.add_dependency 'addressable', '~> 2.3', '>= 2.3.7'
|
|
121
|
+
```
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
#
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
2
3
|
#--
|
|
3
|
-
# Copyright (C)
|
|
4
|
+
# Copyright (C) Bob Aman
|
|
4
5
|
#
|
|
5
6
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
7
|
# you may not use this file except in compliance with the License.
|
|
@@ -28,14 +29,22 @@ module Addressable
|
|
|
28
29
|
IDN::Punycode.decode(value.to_s)
|
|
29
30
|
end
|
|
30
31
|
|
|
31
|
-
|
|
32
|
-
|
|
32
|
+
class << self
|
|
33
|
+
# @deprecated Use {String#unicode_normalize(:nfkc)} instead
|
|
34
|
+
def unicode_normalize_kc(value)
|
|
35
|
+
value.to_s.unicode_normalize(:nfkc)
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
extend Gem::Deprecate
|
|
39
|
+
deprecate :unicode_normalize_kc, "String#unicode_normalize(:nfkc)", 2023, 4
|
|
33
40
|
end
|
|
34
41
|
|
|
35
42
|
def self.to_ascii(value)
|
|
36
43
|
value.to_s.split('.', -1).map do |segment|
|
|
37
|
-
if segment.size > 0
|
|
38
|
-
IDN::Idna.toASCII(segment)
|
|
44
|
+
if segment.size > 0 && segment.size < 64
|
|
45
|
+
IDN::Idna.toASCII(segment, IDN::Idna::ALLOW_UNASSIGNED)
|
|
46
|
+
elsif segment.size >= 64
|
|
47
|
+
segment
|
|
39
48
|
else
|
|
40
49
|
''
|
|
41
50
|
end
|
|
@@ -44,8 +53,10 @@ module Addressable
|
|
|
44
53
|
|
|
45
54
|
def self.to_unicode(value)
|
|
46
55
|
value.to_s.split('.', -1).map do |segment|
|
|
47
|
-
if segment.size > 0
|
|
48
|
-
IDN::Idna.toUnicode(segment)
|
|
56
|
+
if segment.size > 0 && segment.size < 64
|
|
57
|
+
IDN::Idna.toUnicode(segment, IDN::Idna::ALLOW_UNASSIGNED)
|
|
58
|
+
elsif segment.size >= 64
|
|
59
|
+
segment
|
|
49
60
|
else
|
|
50
61
|
''
|
|
51
62
|
end
|