addressable 2.2.4 → 2.2.5
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG +25 -19
- data/LICENSE +202 -20
- data/README.md +76 -0
- data/lib/addressable/idna.rb +24 -4870
- data/lib/addressable/idna/native.rb +43 -0
- data/lib/addressable/idna/pure.rb +4886 -0
- data/lib/addressable/template.rb +40 -42
- data/lib/addressable/uri.rb +157 -187
- data/lib/addressable/version.rb +13 -19
- data/spec/addressable/idna_spec.rb +43 -22
- data/spec/addressable/template_spec.rb +11 -20
- data/spec/addressable/uri_spec.rb +92 -30
- data/tasks/gem.rake +2 -2
- data/tasks/rdoc.rake +1 -1
- data/tasks/spec.rake +5 -3
- data/tasks/yard.rake +4 -4
- metadata +11 -9
- data/README +0 -60
data/lib/addressable/version.rb
CHANGED
@@ -1,34 +1,28 @@
|
|
1
1
|
# encoding:utf-8
|
2
2
|
#--
|
3
|
-
#
|
3
|
+
# Copyright (C) 2006-2011 Bob Aman
|
4
4
|
#
|
5
|
-
#
|
6
|
-
#
|
7
|
-
#
|
8
|
-
# without limitation the rights to use, copy, modify, merge, publish,
|
9
|
-
# distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
-
# permit persons to whom the Software is furnished to do so, subject to
|
11
|
-
# the following conditions:
|
5
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
6
|
+
# you may not use this file except in compliance with the License.
|
7
|
+
# You may obtain a copy of the License at
|
12
8
|
#
|
13
|
-
#
|
14
|
-
# included in all copies or substantial portions of the Software.
|
9
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
15
10
|
#
|
16
|
-
#
|
17
|
-
#
|
18
|
-
#
|
19
|
-
#
|
20
|
-
#
|
21
|
-
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
-
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
11
|
+
# Unless required by applicable law or agreed to in writing, software
|
12
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
13
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
14
|
+
# See the License for the specific language governing permissions and
|
15
|
+
# limitations under the License.
|
23
16
|
#++
|
24
17
|
|
18
|
+
|
25
19
|
# Used to prevent the class/module from being loaded more than once
|
26
20
|
if !defined?(Addressable::VERSION)
|
27
21
|
module Addressable
|
28
|
-
module VERSION
|
22
|
+
module VERSION
|
29
23
|
MAJOR = 2
|
30
24
|
MINOR = 2
|
31
|
-
TINY =
|
25
|
+
TINY = 5
|
32
26
|
|
33
27
|
STRING = [MAJOR, MINOR, TINY].join('.')
|
34
28
|
end
|
@@ -1,30 +1,24 @@
|
|
1
|
-
#
|
2
|
-
#--
|
3
|
-
# Addressable, Copyright (c) 2006-2007 Bob Aman
|
1
|
+
# Copyright (C) 2006-2011 Bob Aman
|
4
2
|
#
|
5
|
-
#
|
6
|
-
#
|
7
|
-
#
|
8
|
-
# without limitation the rights to use, copy, modify, merge, publish,
|
9
|
-
# distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
-
# permit persons to whom the Software is furnished to do so, subject to
|
11
|
-
# the following conditions:
|
3
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
4
|
+
# you may not use this file except in compliance with the License.
|
5
|
+
# You may obtain a copy of the License at
|
12
6
|
#
|
13
|
-
#
|
14
|
-
# included in all copies or substantial portions of the Software.
|
7
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
15
8
|
#
|
16
|
-
#
|
17
|
-
#
|
18
|
-
#
|
19
|
-
#
|
20
|
-
#
|
21
|
-
|
22
|
-
|
23
|
-
|
9
|
+
# Unless required by applicable law or agreed to in writing, software
|
10
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
11
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
12
|
+
# See the License for the specific language governing permissions and
|
13
|
+
# limitations under the License.
|
14
|
+
|
15
|
+
|
16
|
+
# Have to use RubyGems to load the idn gem.
|
17
|
+
require "rubygems"
|
24
18
|
|
25
19
|
require "addressable/idna"
|
26
20
|
|
27
|
-
|
21
|
+
shared_examples_for "converting from unicode to ASCII" do
|
28
22
|
it "should convert 'www.google.com' correctly" do
|
29
23
|
Addressable::IDNA.to_ascii("www.google.com").should == "www.google.com"
|
30
24
|
end
|
@@ -131,7 +125,7 @@ describe Addressable::IDNA, "when converting from unicode to ASCII" do
|
|
131
125
|
end
|
132
126
|
end
|
133
127
|
|
134
|
-
|
128
|
+
shared_examples_for "converting from ASCII to unicode" do
|
135
129
|
it "should convert 'www.google.com' correctly" do
|
136
130
|
Addressable::IDNA.to_unicode("www.google.com").should == "www.google.com"
|
137
131
|
end
|
@@ -192,3 +186,30 @@ describe Addressable::IDNA, "when converting from ASCII to unicode" do
|
|
192
186
|
).should == "\341\206\265"
|
193
187
|
end
|
194
188
|
end
|
189
|
+
|
190
|
+
describe Addressable::IDNA, "when using the pure-Ruby implementation" do
|
191
|
+
before do
|
192
|
+
Addressable.send(:remove_const, :IDNA)
|
193
|
+
load "addressable/idna/pure.rb"
|
194
|
+
end
|
195
|
+
|
196
|
+
it_should_behave_like "converting from unicode to ASCII"
|
197
|
+
it_should_behave_like "converting from ASCII to unicode"
|
198
|
+
end
|
199
|
+
|
200
|
+
begin
|
201
|
+
require "idn"
|
202
|
+
|
203
|
+
describe Addressable::IDNA, "when using the native-code implementation" do
|
204
|
+
before do
|
205
|
+
Addressable.send(:remove_const, :IDNA)
|
206
|
+
load "addressable/idna/native.rb"
|
207
|
+
end
|
208
|
+
|
209
|
+
it_should_behave_like "converting from unicode to ASCII"
|
210
|
+
it_should_behave_like "converting from ASCII to unicode"
|
211
|
+
end
|
212
|
+
rescue LoadError
|
213
|
+
# Cannot test the native implementation without libidn support.
|
214
|
+
warn('Could not load native IDN implementation.')
|
215
|
+
end
|
@@ -1,26 +1,17 @@
|
|
1
|
-
#
|
2
|
-
#--
|
3
|
-
# Addressable, Copyright (c) 2006-2007 Bob Aman
|
1
|
+
# Copyright (C) 2006-2011 Bob Aman
|
4
2
|
#
|
5
|
-
#
|
6
|
-
#
|
7
|
-
#
|
8
|
-
# without limitation the rights to use, copy, modify, merge, publish,
|
9
|
-
# distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
-
# permit persons to whom the Software is furnished to do so, subject to
|
11
|
-
# the following conditions:
|
3
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
4
|
+
# you may not use this file except in compliance with the License.
|
5
|
+
# You may obtain a copy of the License at
|
12
6
|
#
|
13
|
-
#
|
14
|
-
# included in all copies or substantial portions of the Software.
|
7
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
15
8
|
#
|
16
|
-
#
|
17
|
-
#
|
18
|
-
#
|
19
|
-
#
|
20
|
-
#
|
21
|
-
|
22
|
-
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
23
|
-
#++
|
9
|
+
# Unless required by applicable law or agreed to in writing, software
|
10
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
11
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
12
|
+
# See the License for the specific language governing permissions and
|
13
|
+
# limitations under the License.
|
14
|
+
|
24
15
|
|
25
16
|
require "addressable/template"
|
26
17
|
|
@@ -1,26 +1,17 @@
|
|
1
|
-
#
|
2
|
-
#--
|
3
|
-
# Addressable, Copyright (c) 2006-2007 Bob Aman
|
1
|
+
# Copyright (C) 2006-2011 Bob Aman
|
4
2
|
#
|
5
|
-
#
|
6
|
-
#
|
7
|
-
#
|
8
|
-
# without limitation the rights to use, copy, modify, merge, publish,
|
9
|
-
# distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
-
# permit persons to whom the Software is furnished to do so, subject to
|
11
|
-
# the following conditions:
|
3
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
4
|
+
# you may not use this file except in compliance with the License.
|
5
|
+
# You may obtain a copy of the License at
|
12
6
|
#
|
13
|
-
#
|
14
|
-
# included in all copies or substantial portions of the Software.
|
7
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
15
8
|
#
|
16
|
-
#
|
17
|
-
#
|
18
|
-
#
|
19
|
-
#
|
20
|
-
#
|
21
|
-
|
22
|
-
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
23
|
-
#++
|
9
|
+
# Unless required by applicable law or agreed to in writing, software
|
10
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
11
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
12
|
+
# See the License for the specific language governing permissions and
|
13
|
+
# limitations under the License.
|
14
|
+
|
24
15
|
|
25
16
|
require "addressable/uri"
|
26
17
|
|
@@ -328,18 +319,24 @@ describe Addressable::URI, "when created with a path that hasn't been " +
|
|
328
319
|
end
|
329
320
|
|
330
321
|
describe Addressable::URI, "when parsed from an Addressable::URI object" do
|
331
|
-
it "should
|
332
|
-
|
333
|
-
(
|
334
|
-
|
335
|
-
|
322
|
+
it "should not have unexpected side-effects" do
|
323
|
+
original_uri = Addressable::URI.parse("http://example.com/")
|
324
|
+
new_uri = Addressable::URI.parse(original_uri)
|
325
|
+
new_uri.host = 'www.example.com'
|
326
|
+
new_uri.host.should == 'www.example.com'
|
327
|
+
new_uri.to_s.should == 'http://www.example.com/'
|
328
|
+
original_uri.host.should == 'example.com'
|
329
|
+
original_uri.to_s.should == 'http://example.com/'
|
336
330
|
end
|
337
331
|
|
338
|
-
it "should
|
339
|
-
|
340
|
-
(
|
341
|
-
|
342
|
-
|
332
|
+
it "should not have unexpected side-effects" do
|
333
|
+
original_uri = Addressable::URI.parse("http://example.com/")
|
334
|
+
new_uri = Addressable::URI.heuristic_parse(original_uri)
|
335
|
+
new_uri.host = 'www.example.com'
|
336
|
+
new_uri.host.should == 'www.example.com'
|
337
|
+
new_uri.to_s.should == 'http://www.example.com/'
|
338
|
+
original_uri.host.should == 'example.com'
|
339
|
+
original_uri.to_s.should == 'http://example.com/'
|
343
340
|
end
|
344
341
|
end
|
345
342
|
|
@@ -2662,6 +2659,71 @@ describe Addressable::URI, "when parsed from " +
|
|
2662
2659
|
end
|
2663
2660
|
end
|
2664
2661
|
|
2662
|
+
describe Addressable::URI, "when parsed from " +
|
2663
|
+
"'http://example.com/search?q=Q%26A'" do
|
2664
|
+
|
2665
|
+
before do
|
2666
|
+
@uri = Addressable::URI.parse("http://example.com/search?q=Q%26A")
|
2667
|
+
end
|
2668
|
+
|
2669
|
+
it "should have a query of 'q=Q%26A'" do
|
2670
|
+
@uri.query.should == "q=Q%26A"
|
2671
|
+
end
|
2672
|
+
|
2673
|
+
it "should have query_values of {'q' => 'Q&A'}" do
|
2674
|
+
@uri.query_values.should == { 'q' => 'Q&A' }
|
2675
|
+
end
|
2676
|
+
|
2677
|
+
it "should normalize to the original uri (with the ampersand properly percent-encoded)" do
|
2678
|
+
@uri.normalize.to_s.should == "http://example.com/search?q=Q%26A"
|
2679
|
+
end
|
2680
|
+
end
|
2681
|
+
|
2682
|
+
describe Addressable::URI, "when parsed from " +
|
2683
|
+
"'http://example.com/?&x=b'" do
|
2684
|
+
before do
|
2685
|
+
@uri = Addressable::URI.parse("http://example.com/?&x=b")
|
2686
|
+
end
|
2687
|
+
|
2688
|
+
it "should have a query of '&x=b'" do
|
2689
|
+
@uri.query.should == "&x=b"
|
2690
|
+
end
|
2691
|
+
|
2692
|
+
it "should have query_values of {'x' => 'b'}" do
|
2693
|
+
@uri.query_values.should == {'x' => 'b'}
|
2694
|
+
end
|
2695
|
+
end
|
2696
|
+
|
2697
|
+
describe Addressable::URI, "when parsed from " +
|
2698
|
+
"'http://example.com/?&&x=b'" do
|
2699
|
+
before do
|
2700
|
+
@uri = Addressable::URI.parse("http://example.com/?&&x=b")
|
2701
|
+
end
|
2702
|
+
|
2703
|
+
it "should have a query of '&&x=b'" do
|
2704
|
+
@uri.query.should == "&&x=b"
|
2705
|
+
end
|
2706
|
+
|
2707
|
+
it "should have query_values of {'x' => 'b'}" do
|
2708
|
+
@uri.query_values.should == {'x' => 'b'}
|
2709
|
+
end
|
2710
|
+
end
|
2711
|
+
|
2712
|
+
describe Addressable::URI, "when parsed from " +
|
2713
|
+
"'http://example.com/?q=a&&x=b'" do
|
2714
|
+
before do
|
2715
|
+
@uri = Addressable::URI.parse("http://example.com/?q=a&&x=b")
|
2716
|
+
end
|
2717
|
+
|
2718
|
+
it "should have a query of 'q=a&&x=b'" do
|
2719
|
+
@uri.query.should == "q=a&&x=b"
|
2720
|
+
end
|
2721
|
+
|
2722
|
+
it "should have query_values of {'q' => 'a, 'x' => 'b'}" do
|
2723
|
+
@uri.query_values.should == {'q' => 'a', 'x' => 'b'}
|
2724
|
+
end
|
2725
|
+
end
|
2726
|
+
|
2665
2727
|
describe Addressable::URI, "when parsed from " +
|
2666
2728
|
"'http://example.com/?q&&x=b'" do
|
2667
2729
|
before do
|
data/tasks/gem.rake
CHANGED
@@ -10,8 +10,8 @@ namespace :gem do
|
|
10
10
|
s.files = PKG_FILES.to_a
|
11
11
|
|
12
12
|
s.has_rdoc = true
|
13
|
-
s.extra_rdoc_files = %w( README )
|
14
|
-
s.rdoc_options.concat ["--main", "README"]
|
13
|
+
s.extra_rdoc_files = %w( README.md )
|
14
|
+
s.rdoc_options.concat ["--main", "README.md"]
|
15
15
|
|
16
16
|
if !s.respond_to?(:add_development_dependency)
|
17
17
|
puts "Cannot build Gem with this version of RubyGems."
|
data/tasks/rdoc.rake
CHANGED
@@ -8,7 +8,7 @@ namespace :doc do
|
|
8
8
|
rdoc.options << "--line-numbers" << "--inline-source" <<
|
9
9
|
"--accessor" << "cattr_accessor=object" << "--charset" << "utf-8"
|
10
10
|
rdoc.template = "#{ENV["template"]}.rb" if ENV["template"]
|
11
|
-
rdoc.rdoc_files.include("README", "CHANGELOG", "LICENSE")
|
11
|
+
rdoc.rdoc_files.include("README.md", "CHANGELOG", "LICENSE")
|
12
12
|
rdoc.rdoc_files.include("lib/**/*.rb")
|
13
13
|
end
|
14
14
|
|
data/tasks/spec.rake
CHANGED
@@ -3,13 +3,13 @@ namespace :spec do
|
|
3
3
|
t.libs = %w[lib spec]
|
4
4
|
t.spec_files = FileList['spec/**/*_spec.rb']
|
5
5
|
t.spec_opts = ['--color', '--format', 'specdoc']
|
6
|
-
|
6
|
+
|
7
7
|
t.rcov = RCOV_ENABLED
|
8
8
|
t.rcov_opts = [
|
9
9
|
'--exclude', 'spec',
|
10
10
|
'--exclude', '1\\.8\\/gems',
|
11
11
|
'--exclude', '1\\.9\\/gems',
|
12
|
-
'--exclude', 'addressable\\/idna
|
12
|
+
'--exclude', 'addressable\\/idna' # environment dependant
|
13
13
|
]
|
14
14
|
end
|
15
15
|
|
@@ -22,7 +22,9 @@ namespace :spec do
|
|
22
22
|
|
23
23
|
desc "Generate HTML Specdocs for all specs"
|
24
24
|
Spec::Rake::SpecTask.new(:specdoc) do |t|
|
25
|
-
specdoc_path = File.expand_path(
|
25
|
+
specdoc_path = File.expand_path(
|
26
|
+
File.join(File.dirname(__FILE__), '..', 'specdoc')
|
27
|
+
)
|
26
28
|
Dir.mkdir(specdoc_path) if !File.exist?(specdoc_path)
|
27
29
|
|
28
30
|
output_file = File.join(specdoc_path, 'index.html')
|
data/tasks/yard.rake
CHANGED
@@ -8,10 +8,10 @@ begin
|
|
8
8
|
desc "Generate Yardoc documentation"
|
9
9
|
YARD::Rake::YardocTask.new do |yardoc|
|
10
10
|
yardoc.name = "yard"
|
11
|
-
yardoc.options = ["--verbose"]
|
12
|
-
yardoc.files = [
|
13
|
-
"lib/**/*.rb", "ext/**/*.c", "README", "CHANGELOG", "LICENSE"
|
14
|
-
]
|
11
|
+
yardoc.options = ["--verbose", "--markup", "markdown"]
|
12
|
+
yardoc.files = FileList[
|
13
|
+
"lib/**/*.rb", "ext/**/*.c", "README.md", "CHANGELOG", "LICENSE"
|
14
|
+
].exclude(/idna/)
|
15
15
|
end
|
16
16
|
end
|
17
17
|
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: addressable
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
5
|
-
prerelease:
|
4
|
+
hash: 13
|
5
|
+
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 2
|
8
8
|
- 2
|
9
|
-
-
|
10
|
-
version: 2.2.
|
9
|
+
- 5
|
10
|
+
version: 2.2.5
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Bob Aman
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2011-
|
18
|
+
date: 2011-04-09 00:00:00 -07:00
|
19
19
|
default_executable:
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|
@@ -93,8 +93,10 @@ executables: []
|
|
93
93
|
extensions: []
|
94
94
|
|
95
95
|
extra_rdoc_files:
|
96
|
-
- README
|
96
|
+
- README.md
|
97
97
|
files:
|
98
|
+
- lib/addressable/idna/native.rb
|
99
|
+
- lib/addressable/idna/pure.rb
|
98
100
|
- lib/addressable/idna.rb
|
99
101
|
- lib/addressable/template.rb
|
100
102
|
- lib/addressable/uri.rb
|
@@ -114,7 +116,7 @@ files:
|
|
114
116
|
- CHANGELOG
|
115
117
|
- LICENSE
|
116
118
|
- Rakefile
|
117
|
-
- README
|
119
|
+
- README.md
|
118
120
|
has_rdoc: true
|
119
121
|
homepage: http://addressable.rubyforge.org/
|
120
122
|
licenses: []
|
@@ -122,7 +124,7 @@ licenses: []
|
|
122
124
|
post_install_message:
|
123
125
|
rdoc_options:
|
124
126
|
- --main
|
125
|
-
- README
|
127
|
+
- README.md
|
126
128
|
require_paths:
|
127
129
|
- lib
|
128
130
|
required_ruby_version: !ruby/object:Gem::Requirement
|
@@ -146,7 +148,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
146
148
|
requirements: []
|
147
149
|
|
148
150
|
rubyforge_project: addressable
|
149
|
-
rubygems_version: 1.
|
151
|
+
rubygems_version: 1.3.7
|
150
152
|
signing_key:
|
151
153
|
specification_version: 3
|
152
154
|
summary: URI Implementation
|
data/README
DELETED
@@ -1,60 +0,0 @@
|
|
1
|
-
== About
|
2
|
-
|
3
|
-
Homepage:: Addressable[http://addressable.rubyforge.org/]
|
4
|
-
Authors:: Bob Aman (mailto:bob@sporkmonger.com)
|
5
|
-
Copyright:: Copyright 2010 Bob Aman
|
6
|
-
License:: MIT
|
7
|
-
|
8
|
-
Addressable is a replacement for the URI implementation that is part of
|
9
|
-
Ruby's standard library. It more closely conforms to the relevant RFCs and
|
10
|
-
adds support for IRIs and URI templates. Additionally, it provides extensive
|
11
|
-
support for URI templates.
|
12
|
-
|
13
|
-
== Classes
|
14
|
-
- {Addressable::URI}
|
15
|
-
- {Addressable::Template}
|
16
|
-
|
17
|
-
== Example usage
|
18
|
-
require "addressable/uri"
|
19
|
-
|
20
|
-
uri = Addressable::URI.parse("http://example.com/path/to/resource/")
|
21
|
-
uri.scheme
|
22
|
-
#=> "http"
|
23
|
-
uri.host
|
24
|
-
#=> "example.com"
|
25
|
-
uri.path
|
26
|
-
#=> "/path/to/resource/"
|
27
|
-
|
28
|
-
uri = Addressable::URI.parse("http://www.詹姆斯.com/")
|
29
|
-
uri.normalize
|
30
|
-
#=> #<Addressable::URI:0xc9a4c8 URI:http://www.xn--8ws00zhy3a.com/>
|
31
|
-
|
32
|
-
require "addressable/template"
|
33
|
-
|
34
|
-
template = Addressable::Template.new("http://example.com/{-list|+|query}/")
|
35
|
-
template.expand({
|
36
|
-
"query" => "an example query".split(" ")
|
37
|
-
})
|
38
|
-
#=> #<Addressable::URI:0xc9d95c URI:http://example.com/an+example+query/>
|
39
|
-
|
40
|
-
template = Addressable::Template.new(
|
41
|
-
"http://example.com/{-join|&|one,two,three}/"
|
42
|
-
)
|
43
|
-
template.partial_expand({"one" => "1", "three" => 3}).pattern
|
44
|
-
#=> "http://example.com/?one=1{-prefix|&two=|two}&three=3"
|
45
|
-
|
46
|
-
template = Addressable::Template.new(
|
47
|
-
"http://{host}/{-suffix|/|segments}?{-join|&|one,two,bogus}\#{fragment}"
|
48
|
-
)
|
49
|
-
uri = Addressable::URI.parse(
|
50
|
-
"http://example.com/a/b/c/?one=1&two=2#foo"
|
51
|
-
)
|
52
|
-
template.extract(uri)
|
53
|
-
#=>
|
54
|
-
# {
|
55
|
-
# "host" => "example.com",
|
56
|
-
# "segments" => ["a", "b", "c"],
|
57
|
-
# "one" => "1",
|
58
|
-
# "two" => "2",
|
59
|
-
# "fragment" => "foo"
|
60
|
-
# }
|