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