addressable-2.3.4/ 0000755 0000041 0000041 00000000000 12146365675 014040 5 ustar www-data www-data addressable-2.3.4/tasks/ 0000755 0000041 0000041 00000000000 12146365675 015165 5 ustar www-data www-data addressable-2.3.4/tasks/metrics.rake 0000644 0000041 0000041 00000001133 12146365675 017475 0 ustar www-data www-data namespace :metrics do
task :lines do
lines, codelines, total_lines, total_codelines = 0, 0, 0, 0
for file_name in FileList["lib/**/*.rb"]
f = File.open(file_name)
while line = f.gets
lines += 1
next if line =~ /^\s*$/
next if line =~ /^\s*#/
codelines += 1
end
puts "L: #{sprintf("%4d", lines)}, " +
"LOC #{sprintf("%4d", codelines)} | #{file_name}"
total_lines += lines
total_codelines += codelines
lines, codelines = 0, 0
end
puts "Total: Lines #{total_lines}, LOC #{total_codelines}"
end
end
addressable-2.3.4/tasks/git.rake 0000644 0000041 0000041 00000002423 12146365675 016615 0 ustar www-data www-data namespace :git do
namespace :tag do
desc "List tags from the Git repository"
task :list do
tags = `git tag -l`
tags.gsub!("\r", "")
tags = tags.split("\n").sort {|a, b| b <=> a }
puts tags.join("\n")
end
desc "Create a new tag in the Git repository"
task :create do
changelog = File.open("CHANGELOG.md", "r") { |file| file.read }
puts "-" * 80
puts changelog
puts "-" * 80
puts
v = ENV["VERSION"] or abort "Must supply VERSION=x.y.z"
abort "Versions don't match #{v} vs #{PKG_VERSION}" if v != PKG_VERSION
git_status = `git status`
if git_status !~ /nothing to commit \(working directory clean\)/
abort "Working directory isn't clean."
end
tag = "#{PKG_NAME}-#{PKG_VERSION}"
msg = "Release #{PKG_NAME}-#{PKG_VERSION}"
existing_tags = `git tag -l #{PKG_NAME}-*`.split('\n')
if existing_tags.include?(tag)
warn("Tag already exists, deleting...")
unless system "git tag -d #{tag}"
abort "Tag deletion failed."
end
end
puts "Creating git tag '#{tag}'..."
unless system "git tag -a -m \"#{msg}\" #{tag}"
abort "Tag creation failed."
end
end
end
end
task "gem:release" => "git:tag:create"
addressable-2.3.4/tasks/yard.rake 0000644 0000041 0000041 00000001216 12146365675 016770 0 ustar www-data www-data require "rake"
begin
require "yard"
require "yard/rake/yardoc_task"
namespace :doc do
desc "Generate Yardoc documentation"
YARD::Rake::YardocTask.new do |yardoc|
yardoc.name = "yard"
yardoc.options = ["--verbose", "--markup", "markdown"]
yardoc.files = FileList[
"lib/**/*.rb", "ext/**/*.c",
"README.md", "CHANGELOG.md", "LICENSE.txt"
].exclude(/idna/)
end
end
task "clobber" => ["doc:clobber_yard"]
desc "Alias to doc:yard"
task "doc" => "doc:yard"
rescue LoadError
# If yard isn't available, it's not the end of the world
desc "Alias to doc:rdoc"
task "doc" => "doc:rdoc"
end
addressable-2.3.4/tasks/rubyforge.rake 0000644 0000041 0000041 00000005016 12146365675 020037 0 ustar www-data www-data namespace :gem do
desc 'Package and upload to RubyForge'
task :release => ["gem:package", "gem:gemspec"] do |t|
require 'rubyforge'
v = ENV['VERSION'] or abort 'Must supply VERSION=x.y.z'
abort "Versions don't match #{v} vs #{PROJ.version}" if v != PKG_VERSION
pkg = "pkg/#{GEM_SPEC.full_name}"
rf = RubyForge.new
rf.configure
puts 'Logging in...'
rf.login
c = rf.userconfig
changelog = File.open("CHANGELOG.md") { |file| file.read }
c['release_changes'] = changelog
c['preformatted'] = true
files = ["#{pkg}.tgz", "#{pkg}.zip", "#{pkg}.gem"]
puts "Releasing #{PKG_NAME} v. #{PKG_VERSION}"
rf.add_release RUBY_FORGE_PROJECT, PKG_NAME, PKG_VERSION, *files
end
end
namespace :doc do
desc "Publish RDoc to RubyForge"
task :release => ["doc"] do
require "rake/contrib/sshpublisher"
require "yaml"
config = YAML.load(
File.read(File.expand_path('~/.rubyforge/user-config.yml'))
)
host = "#{config['username']}@rubyforge.org"
remote_dir = RUBY_FORGE_PATH + "/api"
local_dir = "doc"
Rake::SshDirPublisher.new(host, remote_dir, local_dir).upload
end
end
namespace :spec do
desc "Publish specdoc to RubyForge"
task :release => ["spec:specdoc"] do
require "rake/contrib/sshpublisher"
require "yaml"
config = YAML.load(
File.read(File.expand_path('~/.rubyforge/user-config.yml'))
)
host = "#{config['username']}@rubyforge.org"
remote_dir = RUBY_FORGE_PATH + "/specdoc"
local_dir = "specdoc"
Rake::SshDirPublisher.new(host, remote_dir, local_dir).upload
end
namespace :rcov do
desc "Publish coverage report to RubyForge"
task :release => ["spec:rcov"] do
require "rake/contrib/sshpublisher"
require "yaml"
config = YAML.load(
File.read(File.expand_path('~/.rubyforge/user-config.yml'))
)
host = "#{config['username']}@rubyforge.org"
remote_dir = RUBY_FORGE_PATH + "/coverage"
local_dir = "coverage"
Rake::SshDirPublisher.new(host, remote_dir, local_dir).upload
end
end
end
namespace :website do
desc "Publish website to RubyForge"
task :release => ["doc:release", "spec:release", "spec:rcov:release"] do
require "rake/contrib/sshpublisher"
require "yaml"
config = YAML.load(
File.read(File.expand_path('~/.rubyforge/user-config.yml'))
)
host = "#{config['username']}@rubyforge.org"
remote_dir = RUBY_FORGE_PATH
local_dir = "website"
Rake::SshDirPublisher.new(host, remote_dir, local_dir).upload
end
end
addressable-2.3.4/tasks/rspec.rake 0000644 0000041 0000041 00000003220 12146365675 017142 0 ustar www-data www-data require "rspec/core/rake_task"
namespace :spec do
RSpec::Core::RakeTask.new(:rcov) do |t|
t.pattern = FileList['spec/**/*_spec.rb']
t.rspec_opts = ['--color', '--format', 'documentation']
t.rcov = RCOV_ENABLED
t.rcov_opts = [
'--exclude', 'lib\\/compat',
'--exclude', 'spec',
'--exclude', '\\.rvm\\/gems',
'--exclude', '1\\.8\\/gems',
'--exclude', '1\\.9\\/gems',
'--exclude', '\\.rvm',
'--exclude', '\\/Library\\/Ruby',
'--exclude', 'addressable\\/idna' # environment dependant
]
end
RSpec::Core::RakeTask.new(:normal) do |t|
t.pattern = FileList['spec/**/*_spec.rb'].exclude(/compat/)
t.rspec_opts = ['--color', '--format', 'documentation']
t.rcov = false
end
RSpec::Core::RakeTask.new(:all) do |t|
t.pattern = FileList['spec/**/*_spec.rb']
t.rspec_opts = ['--color', '--format', 'documentation']
t.rcov = false
end
desc "Generate HTML Specdocs for all specs"
RSpec::Core::RakeTask.new(:specdoc) do |t|
specdoc_path = File.expand_path(
File.join(File.dirname(__FILE__), '..', 'documentation')
)
Dir.mkdir(specdoc_path) if !File.exist?(specdoc_path)
output_file = File.join(specdoc_path, 'index.html')
t.pattern = FileList['spec/**/*_spec.rb']
t.rspec_opts = ["--format", "\"html:#{output_file}\"", "--diff"]
t.fail_on_error = false
end
namespace :rcov do
desc "Browse the code coverage report."
task :browse => "spec:rcov" do
require "launchy"
Launchy::Browser.run("coverage/index.html")
end
end
end
desc "Alias to spec:normal"
task "spec" => "spec:normal"
task "clobber" => ["spec:clobber_rcov"]
addressable-2.3.4/tasks/clobber.rake 0000644 0000041 0000041 00000000060 12146365675 017435 0 ustar www-data www-data desc "Remove all build products"
task "clobber"
addressable-2.3.4/tasks/gem.rake 0000644 0000041 0000041 00000004116 12146365675 016603 0 ustar www-data www-data require "rubygems/package_task"
namespace :gem do
GEM_SPEC = Gem::Specification.new do |s|
s.name = PKG_NAME
s.version = PKG_VERSION
s.summary = PKG_SUMMARY
s.description = PKG_DESCRIPTION
s.files = PKG_FILES.to_a
s.has_rdoc = true
s.extra_rdoc_files = %w( README.md )
s.rdoc_options.concat ["--main", "README.md"]
if !s.respond_to?(:add_development_dependency)
puts "Cannot build Gem with this version of RubyGems."
exit(1)
end
s.add_development_dependency("rake", ">= 0.7.3")
s.add_development_dependency("rspec", ">= 2.9.0")
s.add_development_dependency("launchy", ">= 0.3.2")
s.require_path = "lib"
s.author = "Bob Aman"
s.email = "bob@sporkmonger.com"
s.homepage = RUBY_FORGE_URL
s.rubyforge_project = RUBY_FORGE_PROJECT
s.license = "Apache License 2.0"
end
Gem::PackageTask.new(GEM_SPEC) do |p|
p.gem_spec = GEM_SPEC
p.need_tar = true
p.need_zip = true
end
desc "Generates .gemspec file"
task :gemspec do
spec_string = GEM_SPEC.to_ruby
begin
Thread.new { eval("$SAFE = 3\n#{spec_string}", binding) }.join
rescue
abort "unsafe gemspec: #{$!}"
else
File.open("#{GEM_SPEC.name}.gemspec", 'w') do |file|
file.write spec_string
end
end
end
desc "Show information about the gem"
task :debug do
puts GEM_SPEC.to_ruby
end
desc "Install the gem"
task :install => ["clobber", "gem:package"] do
sh "#{SUDO} gem install --local pkg/#{GEM_SPEC.full_name}"
end
desc "Uninstall the gem"
task :uninstall do
installed_list = Gem.source_index.find_name(PKG_NAME)
if installed_list &&
(installed_list.collect { |s| s.version.to_s}.include?(PKG_VERSION))
sh(
"#{SUDO} gem uninstall --version '#{PKG_VERSION}' " +
"--ignore-dependencies --executables #{PKG_NAME}"
)
end
end
desc "Reinstall the gem"
task :reinstall => [:uninstall, :install]
end
desc "Alias to gem:package"
task "gem" => "gem:package"
task "gem:release" => "gem:gemspec"
task "clobber" => ["gem:clobber_package"]
addressable-2.3.4/README.md 0000644 0000041 0000041 00000004611 12146365675 015321 0 ustar www-data www-data # Addressable
- Homepage
- addressable.rubyforge.org
- Author
- Bob Aman
- Copyright
- Copyright © 2010 Bob Aman
- License
- Apache 2.0
[](http://travis-ci.org/sporkmonger/addressable)
[](https://gemnasium.com/sporkmonger/addressable)
# Description
Addressable is a replacement for the URI implementation that is part of
Ruby's standard library. It more closely conforms to RFC 3986, RFC 3987, and
RFC 6570 (level 4), providing support for IRIs and URI templates.
# Reference
- {Addressable::URI}
- {Addressable::Template}
# Example usage
```ruby
require "addressable/uri"
uri = Addressable::URI.parse("http://example.com/path/to/resource/")
uri.scheme
#=> "http"
uri.host
#=> "example.com"
uri.path
#=> "/path/to/resource/"
uri = Addressable::URI.parse("http://www.詹姆斯.com/")
uri.normalize
#=> #
```
# URI Templates
For more details, see [RFC 6570](https://www.rfc-editor.org/rfc/rfc6570.txt).
```ruby
require "addressable/template"
template = Addressable::Template.new("http://example.com/{?query*}/")
template.expand({
"query" => {
'foo' => 'bar',
'color' => 'red'
}
})
#=> #
template = Addressable::Template.new("http://example.com/{?one,two,three}/")
template.partial_expand({"one" => "1", "three" => 3}).pattern
#=> "http://example.com/?one=1{&two}&three=3"
template = Addressable::Template.new(
"http://{host}{/segments}/{?one,two,bogus}{#fragment}"
)
uri = Addressable::URI.parse(
"http://example.com/a/b/c/?one=1&two=2#foo"
)
template.extract(uri)
#=>
# {
# "host" => "example.com",
# "segments" => ["a", "b", "c"],
# "one" => "1",
# "two" => "2",
# "fragment" => "foo"
# }
```
# Install
```console
$ sudo gem install addressable
```
You may optionally turn on native IDN support by installing libidn and the
idn gem:
```console
$ sudo apt-get install idn # Debian/Ubuntu
$ sudo brew install libidn # OS X
$ sudo gem install idn
```
**NOTE:** Native IDN support appears to be broken in Ruby 1.9.x. The IDN gem
hasn't been updated in years.
addressable-2.3.4/website/ 0000755 0000041 0000041 00000000000 12146365675 015502 5 ustar www-data www-data addressable-2.3.4/website/index.html 0000644 0000041 0000041 00000004372 12146365675 017505 0 ustar www-data www-data
Addressable
Addressable
Addressable is a replacement for the URI implementation that is part
of Ruby's standard library. It more closely conforms to the relevant
RFCs and adds support for IRIs and URI templates.
You know what to do:
sudo gem install addressable
Alternatively, you can:
git submodule add
git://github.com/sporkmonger/addressable.git
vendor/gems/addressable
Addressable works in Ruby 1.8.x, 1.9.x, and JRuby.
addressable-2.3.4/Rakefile 0000644 0000041 0000041 00000002412 12146365675 015504 0 ustar www-data www-data require 'rubygems'
require 'rake'
require File.join(File.dirname(__FILE__), 'lib', 'addressable', 'version')
PKG_DISPLAY_NAME = 'Addressable'
PKG_NAME = PKG_DISPLAY_NAME.downcase
PKG_VERSION = Addressable::VERSION::STRING
PKG_FILE_NAME = "#{PKG_NAME}-#{PKG_VERSION}"
RELEASE_NAME = "REL #{PKG_VERSION}"
RUBY_FORGE_PROJECT = PKG_NAME
RUBY_FORGE_USER = "sporkmonger"
RUBY_FORGE_PATH = "/var/www/gforge-projects/#{RUBY_FORGE_PROJECT}"
RUBY_FORGE_URL = "http://#{RUBY_FORGE_PROJECT}.rubyforge.org/"
PKG_SUMMARY = "URI Implementation"
PKG_DESCRIPTION = <<-TEXT
Addressable is a replacement for the URI implementation that is part of
Ruby's standard library. It more closely conforms to the relevant RFCs and
adds support for IRIs and URI templates.
TEXT
PKG_FILES = FileList[
"lib/**/*", "spec/**/*", "vendor/**/*", "data/**/*",
"tasks/**/*", "website/**/*",
"[A-Z]*", "Rakefile"
].exclude(/database\.yml/).exclude(/Gemfile\.lock/).exclude(/[_\.]git$/)
RCOV_ENABLED = (RUBY_PLATFORM != "java" && RUBY_VERSION =~ /^1\.8/)
task :default => "spec"
WINDOWS = (RUBY_PLATFORM =~ /mswin|win32|mingw|bccwin|cygwin/) rescue false
SUDO = WINDOWS ? '' : ('sudo' unless ENV['SUDOLESS'])
Dir['tasks/**/*.rake'].each { |rake| load rake }
addressable-2.3.4/spec/ 0000755 0000041 0000041 00000000000 12146365675 014772 5 ustar www-data www-data addressable-2.3.4/spec/addressable/ 0000755 0000041 0000041 00000000000 12146365675 017243 5 ustar www-data www-data addressable-2.3.4/spec/addressable/idna_spec.rb 0000644 0000041 0000041 00000020413 12146365675 021515 0 ustar www-data www-data # coding: utf-8
# Copyright (C) 2006-2011 Bob Aman
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# Have to use RubyGems to load the idn gem.
require "rubygems"
require "addressable/idna"
shared_examples_for "converting from unicode to ASCII" do
it "should convert 'www.google.com' correctly" do
Addressable::IDNA.to_ascii("www.google.com").should == "www.google.com"
end
it "should convert 'www.詹姆斯.com' correctly" do
Addressable::IDNA.to_ascii(
"www.詹姆斯.com"
).should == "www.xn--8ws00zhy3a.com"
end
it "should convert 'www.Iñtërnâtiônàlizætiøn.com' correctly" do
"www.Iñtërnâtiônàlizætiøn.com"
Addressable::IDNA.to_ascii(
"www.I\xC3\xB1t\xC3\xABrn\xC3\xA2ti\xC3\xB4" +
"n\xC3\xA0liz\xC3\xA6ti\xC3\xB8n.com"
).should == "www.xn--itrntinliztin-vdb0a5exd8ewcye.com"
end
it "should convert 'www.Iñtërnâtiônàlizætiøn.com' correctly" do
Addressable::IDNA.to_ascii(
"www.In\xCC\x83te\xCC\x88rna\xCC\x82tio\xCC\x82n" +
"a\xCC\x80liz\xC3\xA6ti\xC3\xB8n.com"
).should == "www.xn--itrntinliztin-vdb0a5exd8ewcye.com"
end
it "should convert " +
"'www.ほんとうにながいわけのわからないどめいんめいのらべるまだながくしないとたりない.w3.mag.keio.ac.jp' " +
"correctly" do
Addressable::IDNA.to_ascii(
"www.\343\201\273\343\202\223\343\201\250\343\201\206\343\201\253\343" +
"\201\252\343\201\214\343\201\204\343\202\217\343\201\221\343\201\256" +
"\343\202\217\343\201\213\343\202\211\343\201\252\343\201\204\343\201" +
"\251\343\202\201\343\201\204\343\202\223\343\202\201\343\201\204\343" +
"\201\256\343\202\211\343\201\271\343\202\213\343\201\276\343\201\240" +
"\343\201\252\343\201\214\343\201\217\343\201\227\343\201\252\343\201" +
"\204\343\201\250\343\201\237\343\202\212\343\201\252\343\201\204." +
"w3.mag.keio.ac.jp"
).should ==
"www.xn--n8jaaaaai5bhf7as8fsfk3jnknefdde3" +
"fg11amb5gzdb4wi9bya3kc6lra.w3.mag.keio.ac.jp"
end
it "should convert " +
"'www.ほんとうにながいわけのわからないどめいんめいのらべるまだながくしないとたりない.w3.mag.keio.ac.jp' " +
"correctly" do
Addressable::IDNA.to_ascii(
"www.\343\201\273\343\202\223\343\201\250\343\201\206\343\201\253\343" +
"\201\252\343\201\213\343\202\231\343\201\204\343\202\217\343\201\221" +
"\343\201\256\343\202\217\343\201\213\343\202\211\343\201\252\343\201" +
"\204\343\201\250\343\202\231\343\202\201\343\201\204\343\202\223\343" +
"\202\201\343\201\204\343\201\256\343\202\211\343\201\270\343\202\231" +
"\343\202\213\343\201\276\343\201\237\343\202\231\343\201\252\343\201" +
"\213\343\202\231\343\201\217\343\201\227\343\201\252\343\201\204\343" +
"\201\250\343\201\237\343\202\212\343\201\252\343\201\204." +
"w3.mag.keio.ac.jp"
).should ==
"www.xn--n8jaaaaai5bhf7as8fsfk3jnknefdde3" +
"fg11amb5gzdb4wi9bya3kc6lra.w3.mag.keio.ac.jp"
end
it "should convert '点心和烤鸭.w3.mag.keio.ac.jp' correctly" do
Addressable::IDNA.to_ascii(
"点心和烤鸭.w3.mag.keio.ac.jp"
).should == "xn--0trv4xfvn8el34t.w3.mag.keio.ac.jp"
end
it "should convert '가각갂갃간갅갆갇갈갉힢힣.com' correctly" do
Addressable::IDNA.to_ascii(
"가각갂갃간갅갆갇갈갉힢힣.com"
).should == "xn--o39acdefghijk5883jma.com"
end
it "should convert " +
"'\347\242\274\346\250\231\346\272\226\350" +
"\220\254\345\234\213\347\242\274.com' correctly" do
Addressable::IDNA.to_ascii(
"\347\242\274\346\250\231\346\272\226\350" +
"\220\254\345\234\213\347\242\274.com"
).should == "xn--9cs565brid46mda086o.com"
end
it "should convert 'リ宠퐱〹.com' correctly" do
Addressable::IDNA.to_ascii(
"\357\276\230\345\256\240\355\220\261\343\200\271.com"
).should == "xn--eek174hoxfpr4k.com"
end
it "should convert 'リ宠퐱卄.com' correctly" do
Addressable::IDNA.to_ascii(
"\343\203\252\345\256\240\355\220\261\345\215\204.com"
).should == "xn--eek174hoxfpr4k.com"
end
it "should convert 'ᆵ' correctly" do
Addressable::IDNA.to_ascii(
"\341\206\265"
).should == "xn--4ud"
end
it "should convert 'ᆵ' correctly" do
Addressable::IDNA.to_ascii(
"\357\276\257"
).should == "xn--4ud"
end
end
shared_examples_for "converting from ASCII to unicode" do
it "should convert 'www.google.com' correctly" do
Addressable::IDNA.to_unicode("www.google.com").should == "www.google.com"
end
it "should convert 'www.詹姆斯.com' correctly" do
Addressable::IDNA.to_unicode(
"www.xn--8ws00zhy3a.com"
).should == "www.詹姆斯.com"
end
it "should convert 'www.iñtërnâtiônàlizætiøn.com' correctly" do
Addressable::IDNA.to_unicode(
"www.xn--itrntinliztin-vdb0a5exd8ewcye.com"
).should == "www.iñtërnâtiônàlizætiøn.com"
end
it "should convert " +
"'www.ほんとうにながいわけのわからないどめいんめいのらべるまだながくしないとたりない.w3.mag.keio.ac.jp' " +
"correctly" do
Addressable::IDNA.to_unicode(
"www.xn--n8jaaaaai5bhf7as8fsfk3jnknefdde3" +
"fg11amb5gzdb4wi9bya3kc6lra.w3.mag.keio.ac.jp"
).should ==
"www.ほんとうにながいわけのわからないどめいんめいのらべるまだながくしないとたりない.w3.mag.keio.ac.jp"
end
it "should convert '点心和烤鸭.w3.mag.keio.ac.jp' correctly" do
Addressable::IDNA.to_unicode(
"xn--0trv4xfvn8el34t.w3.mag.keio.ac.jp"
).should == "点心和烤鸭.w3.mag.keio.ac.jp"
end
it "should convert '가각갂갃간갅갆갇갈갉힢힣.com' correctly" do
Addressable::IDNA.to_unicode(
"xn--o39acdefghijk5883jma.com"
).should == "가각갂갃간갅갆갇갈갉힢힣.com"
end
it "should convert " +
"'\347\242\274\346\250\231\346\272\226\350" +
"\220\254\345\234\213\347\242\274.com' correctly" do
Addressable::IDNA.to_unicode(
"xn--9cs565brid46mda086o.com"
).should ==
"\347\242\274\346\250\231\346\272\226\350" +
"\220\254\345\234\213\347\242\274.com"
end
it "should convert 'リ宠퐱卄.com' correctly" do
Addressable::IDNA.to_unicode(
"xn--eek174hoxfpr4k.com"
).should == "\343\203\252\345\256\240\355\220\261\345\215\204.com"
end
it "should convert 'ᆵ' correctly" do
Addressable::IDNA.to_unicode(
"xn--4ud"
).should == "\341\206\265"
end
it "should normalize 'string' correctly" do
Addressable::IDNA.unicode_normalize_kc(:'string').should == "string"
Addressable::IDNA.unicode_normalize_kc("string").should == "string"
end
end
describe Addressable::IDNA, "when using the pure-Ruby implementation" do
before do
Addressable.send(:remove_const, :IDNA)
load "addressable/idna/pure.rb"
end
it_should_behave_like "converting from unicode to ASCII"
it_should_behave_like "converting from ASCII to unicode"
begin
require "fiber"
it "should not blow up inside fibers" do
f = Fiber.new do
Addressable.send(:remove_const, :IDNA)
load "addressable/idna/pure.rb"
end
f.resume
end
rescue LoadError
# Fibers aren't supported in this version of Ruby, skip this test.
warn('Fibers unsupported.')
end
end
begin
require "idn"
describe Addressable::IDNA, "when using the native-code implementation" do
before do
Addressable.send(:remove_const, :IDNA)
load "addressable/idna/native.rb"
end
it_should_behave_like "converting from unicode to ASCII"
it_should_behave_like "converting from ASCII to unicode"
end
rescue LoadError
# Cannot test the native implementation without libidn support.
warn('Could not load native IDN implementation.')
end
addressable-2.3.4/spec/addressable/uri_spec.rb 0000644 0000041 0000041 00000462007 12146365675 021412 0 ustar www-data www-data # coding: utf-8
# Copyright (C) 2006-2011 Bob Aman
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
require "addressable/uri"
if !"".respond_to?("force_encoding")
class String
def force_encoding(encoding)
@encoding = encoding
end
def encoding
@encoding ||= Encoding::ASCII_8BIT
end
end
class Encoding
def initialize(name)
@name = name
end
def to_s
return @name
end
UTF_8 = Encoding.new("UTF-8")
ASCII_8BIT = Encoding.new("US-ASCII")
end
end
module URI
class HTTP
def initialize(uri)
@uri = uri
end
def to_s
return @uri.to_s
end
end
end
describe Addressable::URI, "when created with a non-numeric port number" do
it "should raise an error" do
(lambda do
Addressable::URI.new(:port => "bogus")
end).should raise_error(Addressable::URI::InvalidURIError)
end
end
describe Addressable::URI, "when created with a non-string scheme" do
it "should raise an error" do
(lambda do
Addressable::URI.new(:scheme => :bogus)
end).should raise_error(TypeError)
end
end
describe Addressable::URI, "when created with a non-string user" do
it "should raise an error" do
(lambda do
Addressable::URI.new(:user => :bogus)
end).should raise_error(TypeError)
end
end
describe Addressable::URI, "when created with a non-string password" do
it "should raise an error" do
(lambda do
Addressable::URI.new(:password => :bogus)
end).should raise_error(TypeError)
end
end
describe Addressable::URI, "when created with a non-string userinfo" do
it "should raise an error" do
(lambda do
Addressable::URI.new(:userinfo => :bogus)
end).should raise_error(TypeError)
end
end
describe Addressable::URI, "when created with a non-string host" do
it "should raise an error" do
(lambda do
Addressable::URI.new(:host => :bogus)
end).should raise_error(TypeError)
end
end
describe Addressable::URI, "when created with a non-string authority" do
it "should raise an error" do
(lambda do
Addressable::URI.new(:authority => :bogus)
end).should raise_error(TypeError)
end
end
describe Addressable::URI, "when created with a non-string authority" do
it "should raise an error" do
(lambda do
Addressable::URI.new(:authority => :bogus)
end).should raise_error(TypeError)
end
end
describe Addressable::URI, "when created with a non-string path" do
it "should raise an error" do
(lambda do
Addressable::URI.new(:path => :bogus)
end).should raise_error(TypeError)
end
end
describe Addressable::URI, "when created with a non-string query" do
it "should raise an error" do
(lambda do
Addressable::URI.new(:query => :bogus)
end).should raise_error(TypeError)
end
end
describe Addressable::URI, "when created with a non-string fragment" do
it "should raise an error" do
(lambda do
Addressable::URI.new(:fragment => :bogus)
end).should raise_error(TypeError)
end
end
describe Addressable::URI, "when created with a scheme but no hierarchical " +
"segment" do
it "should raise an error" do
(lambda do
Addressable::URI.parse("http:")
end).should raise_error(Addressable::URI::InvalidURIError)
end
end
describe Addressable::URI, "when created with an invalid host" do
it "should raise an error" do
(lambda do
Addressable::URI.new(:host => "")
end).should raise_error(Addressable::URI::InvalidURIError)
end
end
describe Addressable::URI, "when created from nil components" do
before do
@uri = Addressable::URI.new
end
it "should have a nil site value" do
@uri.site.should == nil
end
it "should have an empty path" do
@uri.path.should == ""
end
it "should be an empty uri" do
@uri.to_s.should == ""
end
it "should have a nil default port" do
@uri.default_port.should == nil
end
it "should raise an error if the scheme is set to whitespace" do
(lambda do
@uri.scheme = "\t \n"
end).should raise_error(Addressable::URI::InvalidURIError)
end
it "should raise an error if the scheme is set to all digits" do
(lambda do
@uri.scheme = "123"
end).should raise_error(Addressable::URI::InvalidURIError)
end
it "should raise an error if set into an invalid state" do
(lambda do
@uri.user = "user"
end).should raise_error(Addressable::URI::InvalidURIError)
end
it "should raise an error if set into an invalid state" do
(lambda do
@uri.password = "pass"
end).should raise_error(Addressable::URI::InvalidURIError)
end
it "should raise an error if set into an invalid state" do
(lambda do
@uri.scheme = "http"
@uri.fragment = "fragment"
end).should raise_error(Addressable::URI::InvalidURIError)
end
it "should raise an error if set into an invalid state" do
(lambda do
@uri.fragment = "fragment"
@uri.scheme = "http"
end).should raise_error(Addressable::URI::InvalidURIError)
end
end
describe Addressable::URI, "when initialized from individual components" do
before do
@uri = Addressable::URI.new(
:scheme => "http",
:user => "user",
:password => "password",
:host => "example.com",
:port => 8080,
:path => "/path",
:query => "query=value",
:fragment => "fragment"
)
end
it "returns 'http' for #scheme" do
@uri.scheme.should == "http"
end
it "returns 'http' for #normalized_scheme" do
@uri.normalized_scheme.should == "http"
end
it "returns 'user' for #user" do
@uri.user.should == "user"
end
it "returns 'user' for #normalized_user" do
@uri.normalized_user.should == "user"
end
it "returns 'password' for #password" do
@uri.password.should == "password"
end
it "returns 'password' for #normalized_password" do
@uri.normalized_password.should == "password"
end
it "returns 'user:password' for #userinfo" do
@uri.userinfo.should == "user:password"
end
it "returns 'user:password' for #normalized_userinfo" do
@uri.normalized_userinfo.should == "user:password"
end
it "returns 'example.com' for #host" do
@uri.host.should == "example.com"
end
it "returns 'example.com' for #normalized_host" do
@uri.normalized_host.should == "example.com"
end
it "returns 'user:password@example.com:8080' for #authority" do
@uri.authority.should == "user:password@example.com:8080"
end
it "returns 'user:password@example.com:8080' for #normalized_authority" do
@uri.normalized_authority.should == "user:password@example.com:8080"
end
it "returns 8080 for #port" do
@uri.port.should == 8080
end
it "returns 8080 for #normalized_port" do
@uri.normalized_port.should == 8080
end
it "returns 80 for #default_port" do
@uri.default_port.should == 80
end
it "returns 'http://user:password@example.com:8080' for #site" do
@uri.site.should == "http://user:password@example.com:8080"
end
it "returns 'http://user:password@example.com:8080' for #normalized_site" do
@uri.normalized_site.should == "http://user:password@example.com:8080"
end
it "returns '/path' for #path" do
@uri.path.should == "/path"
end
it "returns '/path' for #normalized_path" do
@uri.normalized_path.should == "/path"
end
it "returns 'query=value' for #query" do
@uri.query.should == "query=value"
end
it "returns 'query=value' for #normalized_query" do
@uri.normalized_query.should == "query=value"
end
it "returns 'fragment' for #fragment" do
@uri.fragment.should == "fragment"
end
it "returns 'fragment' for #normalized_fragment" do
@uri.normalized_fragment.should == "fragment"
end
it "returns #hash" do
@uri.hash.should_not be nil
end
it "returns #to_s" do
@uri.to_s.should ==
"http://user:password@example.com:8080/path?query=value#fragment"
end
it "should not be frozen" do
@uri.should_not be_frozen
end
it "should allow destructive operations" do
expect { @uri.normalize! }.not_to raise_error
end
end
describe Addressable::URI, "when initialized from " +
"frozen individual components" do
before do
@uri = Addressable::URI.new(
:scheme => "http".freeze,
:user => "user".freeze,
:password => "password".freeze,
:host => "example.com".freeze,
:port => "8080".freeze,
:path => "/path".freeze,
:query => "query=value".freeze,
:fragment => "fragment".freeze
)
end
it "returns 'http' for #scheme" do
@uri.scheme.should == "http"
end
it "returns 'http' for #normalized_scheme" do
@uri.normalized_scheme.should == "http"
end
it "returns 'user' for #user" do
@uri.user.should == "user"
end
it "returns 'user' for #normalized_user" do
@uri.normalized_user.should == "user"
end
it "returns 'password' for #password" do
@uri.password.should == "password"
end
it "returns 'password' for #normalized_password" do
@uri.normalized_password.should == "password"
end
it "returns 'user:password' for #userinfo" do
@uri.userinfo.should == "user:password"
end
it "returns 'user:password' for #normalized_userinfo" do
@uri.normalized_userinfo.should == "user:password"
end
it "returns 'example.com' for #host" do
@uri.host.should == "example.com"
end
it "returns 'example.com' for #normalized_host" do
@uri.normalized_host.should == "example.com"
end
it "returns 'user:password@example.com:8080' for #authority" do
@uri.authority.should == "user:password@example.com:8080"
end
it "returns 'user:password@example.com:8080' for #normalized_authority" do
@uri.normalized_authority.should == "user:password@example.com:8080"
end
it "returns 8080 for #port" do
@uri.port.should == 8080
end
it "returns 8080 for #normalized_port" do
@uri.normalized_port.should == 8080
end
it "returns 80 for #default_port" do
@uri.default_port.should == 80
end
it "returns 'http://user:password@example.com:8080' for #site" do
@uri.site.should == "http://user:password@example.com:8080"
end
it "returns 'http://user:password@example.com:8080' for #normalized_site" do
@uri.normalized_site.should == "http://user:password@example.com:8080"
end
it "returns '/path' for #path" do
@uri.path.should == "/path"
end
it "returns '/path' for #normalized_path" do
@uri.normalized_path.should == "/path"
end
it "returns 'query=value' for #query" do
@uri.query.should == "query=value"
end
it "returns 'query=value' for #normalized_query" do
@uri.normalized_query.should == "query=value"
end
it "returns 'fragment' for #fragment" do
@uri.fragment.should == "fragment"
end
it "returns 'fragment' for #normalized_fragment" do
@uri.normalized_fragment.should == "fragment"
end
it "returns #hash" do
@uri.hash.should_not be nil
end
it "returns #to_s" do
@uri.to_s.should ==
"http://user:password@example.com:8080/path?query=value#fragment"
end
it "should not be frozen" do
@uri.should_not be_frozen
end
it "should allow destructive operations" do
expect { @uri.normalize! }.not_to raise_error
end
end
describe Addressable::URI, "when parsed from a frozen string" do
before do
@uri = Addressable::URI.parse(
"http://user:password@example.com:8080/path?query=value#fragment".freeze
)
end
it "returns 'http' for #scheme" do
@uri.scheme.should == "http"
end
it "returns 'http' for #normalized_scheme" do
@uri.normalized_scheme.should == "http"
end
it "returns 'user' for #user" do
@uri.user.should == "user"
end
it "returns 'user' for #normalized_user" do
@uri.normalized_user.should == "user"
end
it "returns 'password' for #password" do
@uri.password.should == "password"
end
it "returns 'password' for #normalized_password" do
@uri.normalized_password.should == "password"
end
it "returns 'user:password' for #userinfo" do
@uri.userinfo.should == "user:password"
end
it "returns 'user:password' for #normalized_userinfo" do
@uri.normalized_userinfo.should == "user:password"
end
it "returns 'example.com' for #host" do
@uri.host.should == "example.com"
end
it "returns 'example.com' for #normalized_host" do
@uri.normalized_host.should == "example.com"
end
it "returns 'user:password@example.com:8080' for #authority" do
@uri.authority.should == "user:password@example.com:8080"
end
it "returns 'user:password@example.com:8080' for #normalized_authority" do
@uri.normalized_authority.should == "user:password@example.com:8080"
end
it "returns 8080 for #port" do
@uri.port.should == 8080
end
it "returns 8080 for #normalized_port" do
@uri.normalized_port.should == 8080
end
it "returns 80 for #default_port" do
@uri.default_port.should == 80
end
it "returns 'http://user:password@example.com:8080' for #site" do
@uri.site.should == "http://user:password@example.com:8080"
end
it "returns 'http://user:password@example.com:8080' for #normalized_site" do
@uri.normalized_site.should == "http://user:password@example.com:8080"
end
it "returns '/path' for #path" do
@uri.path.should == "/path"
end
it "returns '/path' for #normalized_path" do
@uri.normalized_path.should == "/path"
end
it "returns 'query=value' for #query" do
@uri.query.should == "query=value"
end
it "returns 'query=value' for #normalized_query" do
@uri.normalized_query.should == "query=value"
end
it "returns 'fragment' for #fragment" do
@uri.fragment.should == "fragment"
end
it "returns 'fragment' for #normalized_fragment" do
@uri.normalized_fragment.should == "fragment"
end
it "returns #hash" do
@uri.hash.should_not be nil
end
it "returns #to_s" do
@uri.to_s.should ==
"http://user:password@example.com:8080/path?query=value#fragment"
end
it "should not be frozen" do
@uri.should_not be_frozen
end
it "should allow destructive operations" do
expect { @uri.normalize! }.not_to raise_error
end
end
describe Addressable::URI, "when frozen" do
before do
@uri = Addressable::URI.new.freeze
end
it "returns nil for #scheme" do
@uri.scheme.should == nil
end
it "returns nil for #normalized_scheme" do
@uri.normalized_scheme.should == nil
end
it "returns nil for #user" do
@uri.user.should == nil
end
it "returns nil for #normalized_user" do
@uri.normalized_user.should == nil
end
it "returns nil for #password" do
@uri.password.should == nil
end
it "returns nil for #normalized_password" do
@uri.normalized_password.should == nil
end
it "returns nil for #userinfo" do
@uri.userinfo.should == nil
end
it "returns nil for #normalized_userinfo" do
@uri.normalized_userinfo.should == nil
end
it "returns nil for #host" do
@uri.host.should == nil
end
it "returns nil for #normalized_host" do
@uri.normalized_host.should == nil
end
it "returns nil for #authority" do
@uri.authority.should == nil
end
it "returns nil for #normalized_authority" do
@uri.normalized_authority.should == nil
end
it "returns nil for #port" do
@uri.port.should == nil
end
it "returns nil for #normalized_port" do
@uri.normalized_port.should == nil
end
it "returns nil for #default_port" do
@uri.default_port.should == nil
end
it "returns nil for #site" do
@uri.site.should == nil
end
it "returns nil for #normalized_site" do
@uri.normalized_site.should == nil
end
it "returns '' for #path" do
@uri.path.should == ''
end
it "returns '' for #normalized_path" do
@uri.normalized_path.should == ''
end
it "returns nil for #query" do
@uri.query.should == nil
end
it "returns nil for #normalized_query" do
@uri.normalized_query.should == nil
end
it "returns nil for #fragment" do
@uri.fragment.should == nil
end
it "returns nil for #normalized_fragment" do
@uri.normalized_fragment.should == nil
end
it "returns #hash" do
@uri.hash.should_not be nil
end
it "returns #to_s" do
@uri.to_s.should == ''
end
it "should be frozen" do
@uri.should be_frozen
end
it "should not be frozen after duping" do
@uri.dup.should_not be_frozen
end
it "should not allow destructive operations" do
expect { @uri.normalize! }.to raise_error { |error|
error.message.should match(/can't modify frozen/)
error.should satisfy { |e| RuntimeError === e || TypeError === e }
}
end
end
describe Addressable::URI, "when frozen" do
before do
@uri = Addressable::URI.parse(
"HTTP://example.com.:%38%30/%70a%74%68?a=%31#1%323"
).freeze
end
it "returns 'HTTP' for #scheme" do
@uri.scheme.should == "HTTP"
end
it "returns 'http' for #normalized_scheme" do
@uri.normalized_scheme.should == "http"
@uri.normalize.scheme.should == "http"
end
it "returns nil for #user" do
@uri.user.should == nil
end
it "returns nil for #normalized_user" do
@uri.normalized_user.should == nil
end
it "returns nil for #password" do
@uri.password.should == nil
end
it "returns nil for #normalized_password" do
@uri.normalized_password.should == nil
end
it "returns nil for #userinfo" do
@uri.userinfo.should == nil
end
it "returns nil for #normalized_userinfo" do
@uri.normalized_userinfo.should == nil
end
it "returns 'example.com.' for #host" do
@uri.host.should == "example.com."
end
it "returns nil for #normalized_host" do
@uri.normalized_host.should == "example.com"
@uri.normalize.host.should == "example.com"
end
it "returns 'example.com.:80' for #authority" do
@uri.authority.should == "example.com.:80"
end
it "returns 'example.com:80' for #normalized_authority" do
@uri.normalized_authority.should == "example.com"
@uri.normalize.authority.should == "example.com"
end
it "returns 80 for #port" do
@uri.port.should == 80
end
it "returns nil for #normalized_port" do
@uri.normalized_port.should == nil
@uri.normalize.port.should == nil
end
it "returns 80 for #default_port" do
@uri.default_port.should == 80
end
it "returns 'HTTP://example.com.:80' for #site" do
@uri.site.should == "HTTP://example.com.:80"
end
it "returns 'http://example.com' for #normalized_site" do
@uri.normalized_site.should == "http://example.com"
@uri.normalize.site.should == "http://example.com"
end
it "returns '/%70a%74%68' for #path" do
@uri.path.should == "/%70a%74%68"
end
it "returns '/path' for #normalized_path" do
@uri.normalized_path.should == "/path"
@uri.normalize.path.should == "/path"
end
it "returns 'a=%31' for #query" do
@uri.query.should == "a=%31"
end
it "returns 'a=1' for #normalized_query" do
@uri.normalized_query.should == "a=1"
@uri.normalize.query.should == "a=1"
end
it "returns '1%323' for #fragment" do
@uri.fragment.should == "1%323"
end
it "returns '123' for #normalized_fragment" do
@uri.normalized_fragment.should == "123"
@uri.normalize.fragment.should == "123"
end
it "returns #hash" do
@uri.hash.should_not be nil
end
it "returns #to_s" do
@uri.to_s.should == 'HTTP://example.com.:80/%70a%74%68?a=%31#1%323'
@uri.normalize.to_s.should == 'http://example.com/path?a=1#123'
end
it "should be frozen" do
@uri.should be_frozen
end
it "should not be frozen after duping" do
@uri.dup.should_not be_frozen
end
it "should not allow destructive operations" do
expect { @uri.normalize! }.to raise_error { |error|
error.message.should match(/can't modify frozen/)
error.should satisfy { |e| RuntimeError === e || TypeError === e }
}
end
end
describe Addressable::URI, "when created from string components" do
before do
@uri = Addressable::URI.new(
:scheme => "http", :host => "example.com"
)
end
it "should have a site value of 'http://example.com'" do
@uri.site.should == "http://example.com"
end
it "should be equal to the equivalent parsed URI" do
@uri.should == Addressable::URI.parse("http://example.com")
end
it "should raise an error if invalid components omitted" do
(lambda do
@uri.omit(:bogus)
end).should raise_error(ArgumentError)
(lambda do
@uri.omit(:scheme, :bogus, :path)
end).should raise_error(ArgumentError)
end
end
describe Addressable::URI, "when created with a nil host but " +
"non-nil authority components" do
it "should raise an error" do
(lambda do
Addressable::URI.new(:user => "user", :password => "pass", :port => 80)
end).should raise_error(Addressable::URI::InvalidURIError)
end
end
describe Addressable::URI, "when created with both an authority and a user" do
it "should raise an error" do
(lambda do
Addressable::URI.new(
:user => "user", :authority => "user@example.com:80"
)
end).should raise_error(ArgumentError)
end
end
describe Addressable::URI, "when created with an authority and no port" do
before do
@uri = Addressable::URI.new(:authority => "user@example.com")
end
it "should not infer a port" do
@uri.port.should == nil
@uri.default_port.should == nil
@uri.inferred_port.should == nil
end
it "should have a site value of '//user@example.com'" do
@uri.site.should == "//user@example.com"
end
it "should have a 'null' origin" do
@uri.origin.should == 'null'
end
end
describe Addressable::URI, "when created with both a userinfo and a user" do
it "should raise an error" do
(lambda do
Addressable::URI.new(:user => "user", :userinfo => "user:pass")
end).should raise_error(ArgumentError)
end
end
describe Addressable::URI, "when created with a path that hasn't been " +
"prefixed with a '/' but a host specified" do
before do
@uri = Addressable::URI.new(
:scheme => "http", :host => "example.com", :path => "path"
)
end
it "should prefix a '/' to the path" do
@uri.should == Addressable::URI.parse("http://example.com/path")
end
it "should have a site value of 'http://example.com'" do
@uri.site.should == "http://example.com"
end
it "should have an origin of 'http://example.com" do
@uri.origin.should == 'http://example.com'
end
end
describe Addressable::URI, "when created with a path that hasn't been " +
"prefixed with a '/' but no host specified" do
before do
@uri = Addressable::URI.new(
:scheme => "http", :path => "path"
)
end
it "should not prefix a '/' to the path" do
@uri.should == Addressable::URI.parse("http:path")
end
it "should have a site value of 'http:'" do
@uri.site.should == "http:"
end
it "should have a 'null' origin" do
@uri.origin.should == 'null'
end
end
describe Addressable::URI, "when parsed from an Addressable::URI object" do
it "should not have unexpected side-effects" do
original_uri = Addressable::URI.parse("http://example.com/")
new_uri = Addressable::URI.parse(original_uri)
new_uri.host = 'www.example.com'
new_uri.host.should == 'www.example.com'
new_uri.to_s.should == 'http://www.example.com/'
original_uri.host.should == 'example.com'
original_uri.to_s.should == 'http://example.com/'
end
it "should not have unexpected side-effects" do
original_uri = Addressable::URI.parse("http://example.com/")
new_uri = Addressable::URI.heuristic_parse(original_uri)
new_uri.host = 'www.example.com'
new_uri.host.should == 'www.example.com'
new_uri.to_s.should == 'http://www.example.com/'
original_uri.host.should == 'example.com'
original_uri.to_s.should == 'http://example.com/'
end
end
describe Addressable::URI, "when parsed from something that looks " +
"like a URI object" do
it "should parse without error" do
uri = Addressable::URI.parse(URI::HTTP.new("http://example.com/"))
(lambda do
Addressable::URI.parse(uri)
end).should_not raise_error
end
end
describe Addressable::URI, "when parsed from ''" do
before do
@uri = Addressable::URI.parse("")
end
it "should have no scheme" do
@uri.scheme.should == nil
end
it "should not be considered to be ip-based" do
@uri.should_not be_ip_based
end
it "should have a path of ''" do
@uri.path.should == ""
end
it "should have a request URI of '/'" do
@uri.request_uri.should == "/"
end
it "should be considered relative" do
@uri.should be_relative
end
it "should be considered to be in normal form" do
@uri.normalize.should be_eql(@uri)
end
it "should have a 'null' origin" do
@uri.origin.should == 'null'
end
end
# Section 1.1.2 of RFC 3986
describe Addressable::URI, "when parsed from " +
"'ftp://ftp.is.co.za/rfc/rfc1808.txt'" do
before do
@uri = Addressable::URI.parse("ftp://ftp.is.co.za/rfc/rfc1808.txt")
end
it "should use the 'ftp' scheme" do
@uri.scheme.should == "ftp"
end
it "should be considered to be ip-based" do
@uri.should be_ip_based
end
it "should have a host of 'ftp.is.co.za'" do
@uri.host.should == "ftp.is.co.za"
end
it "should have inferred_port of 21" do
@uri.inferred_port.should == 21
end
it "should have a path of '/rfc/rfc1808.txt'" do
@uri.path.should == "/rfc/rfc1808.txt"
end
it "should not have a request URI" do
@uri.request_uri.should == nil
end
it "should be considered to be in normal form" do
@uri.normalize.should be_eql(@uri)
end
it "should have an origin of 'ftp://ftp.is.co.za'" do
@uri.origin.should == 'ftp://ftp.is.co.za'
end
end
# Section 1.1.2 of RFC 3986
describe Addressable::URI, "when parsed from " +
"'http://www.ietf.org/rfc/rfc2396.txt'" do
before do
@uri = Addressable::URI.parse("http://www.ietf.org/rfc/rfc2396.txt")
end
it "should use the 'http' scheme" do
@uri.scheme.should == "http"
end
it "should be considered to be ip-based" do
@uri.should be_ip_based
end
it "should have a host of 'www.ietf.org'" do
@uri.host.should == "www.ietf.org"
end
it "should have inferred_port of 80" do
@uri.inferred_port.should == 80
end
it "should have a path of '/rfc/rfc2396.txt'" do
@uri.path.should == "/rfc/rfc2396.txt"
end
it "should have a request URI of '/rfc/rfc2396.txt'" do
@uri.request_uri.should == "/rfc/rfc2396.txt"
end
it "should be considered to be in normal form" do
@uri.normalize.should be_eql(@uri)
end
it "should correctly omit components" do
@uri.omit(:scheme).to_s.should == "//www.ietf.org/rfc/rfc2396.txt"
@uri.omit(:path).to_s.should == "http://www.ietf.org"
end
it "should correctly omit components destructively" do
@uri.omit!(:scheme)
@uri.to_s.should == "//www.ietf.org/rfc/rfc2396.txt"
end
it "should have an origin of 'http://www.ietf.org'" do
@uri.origin.should == 'http://www.ietf.org'
end
end
# Section 1.1.2 of RFC 3986
describe Addressable::URI, "when parsed from " +
"'ldap://[2001:db8::7]/c=GB?objectClass?one'" do
before do
@uri = Addressable::URI.parse("ldap://[2001:db8::7]/c=GB?objectClass?one")
end
it "should use the 'ldap' scheme" do
@uri.scheme.should == "ldap"
end
it "should be considered to be ip-based" do
@uri.should be_ip_based
end
it "should have a host of '[2001:db8::7]'" do
@uri.host.should == "[2001:db8::7]"
end
it "should have inferred_port of 389" do
@uri.inferred_port.should == 389
end
it "should have a path of '/c=GB'" do
@uri.path.should == "/c=GB"
end
it "should not have a request URI" do
@uri.request_uri.should == nil
end
it "should not allow request URI assignment" do
(lambda do
@uri.request_uri = "/"
end).should raise_error(Addressable::URI::InvalidURIError)
end
it "should have a query of 'objectClass?one'" do
@uri.query.should == "objectClass?one"
end
it "should be considered to be in normal form" do
@uri.normalize.should be_eql(@uri)
end
it "should correctly omit components" do
@uri.omit(:scheme, :authority).to_s.should == "/c=GB?objectClass?one"
@uri.omit(:path).to_s.should == "ldap://[2001:db8::7]?objectClass?one"
end
it "should correctly omit components destructively" do
@uri.omit!(:scheme, :authority)
@uri.to_s.should == "/c=GB?objectClass?one"
end
it "should raise an error if omission would create an invalid URI" do
(lambda do
@uri.omit(:authority, :path)
end).should raise_error(Addressable::URI::InvalidURIError)
end
it "should have an origin of 'ldap://[2001:db8::7]'" do
@uri.origin.should == 'ldap://[2001:db8::7]'
end
end
# Section 1.1.2 of RFC 3986
describe Addressable::URI, "when parsed from " +
"'mailto:John.Doe@example.com'" do
before do
@uri = Addressable::URI.parse("mailto:John.Doe@example.com")
end
it "should use the 'mailto' scheme" do
@uri.scheme.should == "mailto"
end
it "should not be considered to be ip-based" do
@uri.should_not be_ip_based
end
it "should not have an inferred_port" do
@uri.inferred_port.should == nil
end
it "should have a path of 'John.Doe@example.com'" do
@uri.path.should == "John.Doe@example.com"
end
it "should not have a request URI" do
@uri.request_uri.should == nil
end
it "should be considered to be in normal form" do
@uri.normalize.should be_eql(@uri)
end
it "should have a 'null' origin" do
@uri.origin.should == 'null'
end
end
# Section 1.1.2 of RFC 3986
describe Addressable::URI, "when parsed from " +
"'news:comp.infosystems.www.servers.unix'" do
before do
@uri = Addressable::URI.parse("news:comp.infosystems.www.servers.unix")
end
it "should use the 'news' scheme" do
@uri.scheme.should == "news"
end
it "should not have an inferred_port" do
@uri.inferred_port.should == nil
end
it "should not be considered to be ip-based" do
@uri.should_not be_ip_based
end
it "should have a path of 'comp.infosystems.www.servers.unix'" do
@uri.path.should == "comp.infosystems.www.servers.unix"
end
it "should not have a request URI" do
@uri.request_uri.should == nil
end
it "should be considered to be in normal form" do
@uri.normalize.should be_eql(@uri)
end
it "should have a 'null' origin" do
@uri.origin.should == 'null'
end
end
# Section 1.1.2 of RFC 3986
describe Addressable::URI, "when parsed from " +
"'tel:+1-816-555-1212'" do
before do
@uri = Addressable::URI.parse("tel:+1-816-555-1212")
end
it "should use the 'tel' scheme" do
@uri.scheme.should == "tel"
end
it "should not be considered to be ip-based" do
@uri.should_not be_ip_based
end
it "should not have an inferred_port" do
@uri.inferred_port.should == nil
end
it "should have a path of '+1-816-555-1212'" do
@uri.path.should == "+1-816-555-1212"
end
it "should not have a request URI" do
@uri.request_uri.should == nil
end
it "should be considered to be in normal form" do
@uri.normalize.should be_eql(@uri)
end
it "should have a 'null' origin" do
@uri.origin.should == 'null'
end
end
# Section 1.1.2 of RFC 3986
describe Addressable::URI, "when parsed from " +
"'telnet://192.0.2.16:80/'" do
before do
@uri = Addressable::URI.parse("telnet://192.0.2.16:80/")
end
it "should use the 'telnet' scheme" do
@uri.scheme.should == "telnet"
end
it "should have a host of '192.0.2.16'" do
@uri.host.should == "192.0.2.16"
end
it "should have a port of 80" do
@uri.port.should == 80
end
it "should have a inferred_port of 80" do
@uri.inferred_port.should == 80
end
it "should have a default_port of 23" do
@uri.default_port.should == 23
end
it "should be considered to be ip-based" do
@uri.should be_ip_based
end
it "should have a path of '/'" do
@uri.path.should == "/"
end
it "should not have a request URI" do
@uri.request_uri.should == nil
end
it "should be considered to be in normal form" do
@uri.normalize.should be_eql(@uri)
end
it "should have an origin of 'telnet://192.0.2.16:80'" do
@uri.origin.should == 'telnet://192.0.2.16:80'
end
end
# Section 1.1.2 of RFC 3986
describe Addressable::URI, "when parsed from " +
"'urn:oasis:names:specification:docbook:dtd:xml:4.1.2'" do
before do
@uri = Addressable::URI.parse(
"urn:oasis:names:specification:docbook:dtd:xml:4.1.2")
end
it "should use the 'urn' scheme" do
@uri.scheme.should == "urn"
end
it "should not have an inferred_port" do
@uri.inferred_port.should == nil
end
it "should not be considered to be ip-based" do
@uri.should_not be_ip_based
end
it "should have a path of " +
"'oasis:names:specification:docbook:dtd:xml:4.1.2'" do
@uri.path.should == "oasis:names:specification:docbook:dtd:xml:4.1.2"
end
it "should not have a request URI" do
@uri.request_uri.should == nil
end
it "should be considered to be in normal form" do
@uri.normalize.should be_eql(@uri)
end
it "should have a 'null' origin" do
@uri.origin.should == 'null'
end
end
describe Addressable::URI, "when heuristically parsed from " +
"'192.0.2.16:8000/path'" do
before do
@uri = Addressable::URI.heuristic_parse("192.0.2.16:8000/path")
end
it "should use the 'http' scheme" do
@uri.scheme.should == "http"
end
it "should have a host of '192.0.2.16'" do
@uri.host.should == "192.0.2.16"
end
it "should have a port of '8000'" do
@uri.port.should == 8000
end
it "should be considered to be ip-based" do
@uri.should be_ip_based
end
it "should have a path of '/path'" do
@uri.path.should == "/path"
end
it "should be considered to be in normal form" do
@uri.normalize.should be_eql(@uri)
end
it "should have an origin of 'http://192.0.2.16:8000'" do
@uri.origin.should == 'http://192.0.2.16:8000'
end
end
describe Addressable::URI, "when parsed from " +
"'http://example.com'" do
before do
@uri = Addressable::URI.parse("http://example.com")
end
it "when inspected, should have the correct URI" do
@uri.inspect.should include("http://example.com")
end
it "when inspected, should have the correct class name" do
@uri.inspect.should include("Addressable::URI")
end
it "when inspected, should have the correct object id" do
@uri.inspect.should include("%#0x" % @uri.object_id)
end
it "should use the 'http' scheme" do
@uri.scheme.should == "http"
end
it "should be considered to be ip-based" do
@uri.should be_ip_based
end
it "should have an authority segment of 'example.com'" do
@uri.authority.should == "example.com"
end
it "should have a host of 'example.com'" do
@uri.host.should == "example.com"
end
it "should be considered ip-based" do
@uri.should be_ip_based
end
it "should have no username" do
@uri.user.should == nil
end
it "should have no password" do
@uri.password.should == nil
end
it "should use port 80" do
@uri.inferred_port.should == 80
end
it "should not have a specified port" do
@uri.port.should == nil
end
it "should have an empty path" do
@uri.path.should == ""
end
it "should have no query string" do
@uri.query.should == nil
@uri.query_values.should == nil
end
it "should have a request URI of '/'" do
@uri.request_uri.should == "/"
end
it "should have no fragment" do
@uri.fragment.should == nil
end
it "should be considered absolute" do
@uri.should be_absolute
end
it "should not be considered relative" do
@uri.should_not be_relative
end
it "should not be exactly equal to 42" do
@uri.eql?(42).should == false
end
it "should not be equal to 42" do
(@uri == 42).should == false
end
it "should not be roughly equal to 42" do
(@uri === 42).should == false
end
it "should be exactly equal to http://example.com" do
@uri.eql?(Addressable::URI.parse("http://example.com")).should == true
end
it "should be roughly equal to http://example.com/" do
(@uri === Addressable::URI.parse("http://example.com/")).should == true
end
it "should be roughly equal to the string 'http://example.com/'" do
(@uri === "http://example.com/").should == true
end
it "should not be roughly equal to the string " +
"'http://example.com:bogus/'" do
(lambda do
(@uri === "http://example.com:bogus/").should == false
end).should_not raise_error
end
it "should result in itself when joined with itself" do
@uri.join(@uri).to_s.should == "http://example.com"
@uri.join!(@uri).to_s.should == "http://example.com"
end
it "should be equivalent to http://EXAMPLE.com" do
@uri.should == Addressable::URI.parse("http://EXAMPLE.com")
end
it "should be equivalent to http://EXAMPLE.com:80/" do
@uri.should == Addressable::URI.parse("http://EXAMPLE.com:80/")
end
it "should have the same hash as http://example.com" do
@uri.hash.should == Addressable::URI.parse("http://example.com").hash
end
it "should have the same hash as http://EXAMPLE.com after assignment" do
@uri.host = "EXAMPLE.com"
@uri.hash.should == Addressable::URI.parse("http://EXAMPLE.com").hash
end
it "should have a different hash from http://EXAMPLE.com" do
@uri.hash.should_not == Addressable::URI.parse("http://EXAMPLE.com").hash
end
# Section 6.2.3 of RFC 3986
it "should be equivalent to http://example.com/" do
@uri.should == Addressable::URI.parse("http://example.com/")
end
# Section 6.2.3 of RFC 3986
it "should be equivalent to http://example.com:/" do
@uri.should == Addressable::URI.parse("http://example.com:/")
end
# Section 6.2.3 of RFC 3986
it "should be equivalent to http://example.com:80/" do
@uri.should == Addressable::URI.parse("http://example.com:80/")
end
# Section 6.2.2.1 of RFC 3986
it "should be equivalent to http://EXAMPLE.COM/" do
@uri.should == Addressable::URI.parse("http://EXAMPLE.COM/")
end
it "should have a route of '/path/' to 'http://example.com/path/'" do
@uri.route_to("http://example.com/path/").should ==
Addressable::URI.parse("/path/")
end
it "should have a route of '/' from 'http://example.com/path/'" do
@uri.route_from("http://example.com/path/").should ==
Addressable::URI.parse("/")
end
it "should have a route of '#' to 'http://example.com/'" do
@uri.route_to("http://example.com/").should ==
Addressable::URI.parse("#")
end
it "should have a route of 'http://elsewhere.com/' to " +
"'http://elsewhere.com/'" do
@uri.route_to("http://elsewhere.com/").should ==
Addressable::URI.parse("http://elsewhere.com/")
end
it "when joined with 'relative/path' should be " +
"'http://example.com/relative/path'" do
@uri.join('relative/path').should ==
Addressable::URI.parse("http://example.com/relative/path")
end
it "when joined with a bogus object a TypeError should be raised" do
(lambda do
@uri.join(42)
end).should raise_error(TypeError)
end
it "should have the correct username after assignment" do
@uri.user = "newuser"
@uri.user.should == "newuser"
@uri.password.should == nil
@uri.to_s.should == "http://newuser@example.com"
end
it "should have the correct username after assignment" do
@uri.user = "user@123!"
@uri.user.should == "user@123!"
@uri.normalized_user.should == "user%40123%21"
@uri.password.should == nil
@uri.normalize.to_s.should == "http://user%40123%21@example.com/"
end
it "should have the correct password after assignment" do
@uri.password = "newpass"
@uri.password.should == "newpass"
@uri.user.should == ""
@uri.to_s.should == "http://:newpass@example.com"
end
it "should have the correct password after assignment" do
@uri.password = "#secret@123!"
@uri.password.should == "#secret@123!"
@uri.normalized_password.should == "%23secret%40123%21"
@uri.user.should == ""
@uri.normalize.to_s.should == "http://:%23secret%40123%21@example.com/"
@uri.omit(:password).to_s.should == "http://example.com"
end
it "should have the correct user/pass after repeated assignment" do
@uri.user = nil
@uri.user.should == nil
@uri.password = "newpass"
@uri.password.should == "newpass"
# Username cannot be nil if the password is set
@uri.user.should == ""
@uri.to_s.should == "http://:newpass@example.com"
@uri.user = "newuser"
@uri.user.should == "newuser"
@uri.password = nil
@uri.password.should == nil
@uri.to_s.should == "http://newuser@example.com"
@uri.user = "newuser"
@uri.user.should == "newuser"
@uri.password = ""
@uri.password.should == ""
@uri.to_s.should == "http://newuser:@example.com"
@uri.password = "newpass"
@uri.password.should == "newpass"
@uri.user = nil
# Username cannot be nil if the password is set
@uri.user.should == ""
@uri.to_s.should == "http://:newpass@example.com"
end
it "should have the correct user/pass after userinfo assignment" do
@uri.user = "newuser"
@uri.user.should == "newuser"
@uri.password = "newpass"
@uri.password.should == "newpass"
@uri.userinfo = nil
@uri.userinfo.should == nil
@uri.user.should == nil
@uri.password.should == nil
end
it "should correctly convert to a hash" do
@uri.to_hash.should == {
:scheme => "http",
:user => nil,
:password => nil,
:host => "example.com",
:port => nil,
:path => "",
:query => nil,
:fragment => nil
}
end
it "should be identical to its duplicate" do
@uri.should == @uri.dup
end
it "should have an origin of 'http://example.com'" do
@uri.origin.should == 'http://example.com'
end
end
# Section 5.1.2 of RFC 2616
describe Addressable::URI, "when parsed from " +
"'http://www.w3.org/pub/WWW/TheProject.html'" do
before do
@uri = Addressable::URI.parse("http://www.w3.org/pub/WWW/TheProject.html")
end
it "should have the correct request URI" do
@uri.request_uri.should == "/pub/WWW/TheProject.html"
end
it "should have the correct request URI after assignment" do
@uri.request_uri = "/some/where/else.html?query?string"
@uri.request_uri.should == "/some/where/else.html?query?string"
@uri.path.should == "/some/where/else.html"
@uri.query.should == "query?string"
end
it "should have the correct request URI after assignment" do
@uri.request_uri = "?x=y"
@uri.request_uri.should == "/?x=y"
@uri.path.should == "/"
@uri.query.should == "x=y"
end
it "should raise an error if the site value is set to something bogus" do
(lambda do
@uri.site = 42
end).should raise_error(TypeError)
end
it "should raise an error if the request URI is set to something bogus" do
(lambda do
@uri.request_uri = 42
end).should raise_error(TypeError)
end
it "should correctly convert to a hash" do
@uri.to_hash.should == {
:scheme => "http",
:user => nil,
:password => nil,
:host => "www.w3.org",
:port => nil,
:path => "/pub/WWW/TheProject.html",
:query => nil,
:fragment => nil
}
end
it "should have an origin of 'http://www.w3.org'" do
@uri.origin.should == 'http://www.w3.org'
end
end
describe Addressable::URI, "when parsing IPv6 addresses" do
it "should not raise an error for " +
"'http://[3ffe:1900:4545:3:200:f8ff:fe21:67cf]/'" do
Addressable::URI.parse("http://[3ffe:1900:4545:3:200:f8ff:fe21:67cf]/")
end
it "should not raise an error for " +
"'http://[fe80:0:0:0:200:f8ff:fe21:67cf]/'" do
Addressable::URI.parse("http://[fe80:0:0:0:200:f8ff:fe21:67cf]/")
end
it "should not raise an error for " +
"'http://[fe80::200:f8ff:fe21:67cf]/'" do
Addressable::URI.parse("http://[fe80::200:f8ff:fe21:67cf]/")
end
it "should not raise an error for " +
"'http://[::1]/'" do
Addressable::URI.parse("http://[::1]/")
end
it "should not raise an error for " +
"'http://[fe80::1]/'" do
Addressable::URI.parse("http://[fe80::1]/")
end
it "should raise an error for " +
"'http://[]/'" do
(lambda do
Addressable::URI.parse("http://[]/")
end).should raise_error(Addressable::URI::InvalidURIError)
end
end
describe Addressable::URI, "when parsing IPvFuture addresses" do
it "should not raise an error for " +
"'http://[v9.3ffe:1900:4545:3:200:f8ff:fe21:67cf]/'" do
Addressable::URI.parse("http://[v9.3ffe:1900:4545:3:200:f8ff:fe21:67cf]/")
end
it "should not raise an error for " +
"'http://[vff.fe80:0:0:0:200:f8ff:fe21:67cf]/'" do
Addressable::URI.parse("http://[vff.fe80:0:0:0:200:f8ff:fe21:67cf]/")
end
it "should not raise an error for " +
"'http://[v12.fe80::200:f8ff:fe21:67cf]/'" do
Addressable::URI.parse("http://[v12.fe80::200:f8ff:fe21:67cf]/")
end
it "should not raise an error for " +
"'http://[va0.::1]/'" do
Addressable::URI.parse("http://[va0.::1]/")
end
it "should not raise an error for " +
"'http://[v255.fe80::1]/'" do
Addressable::URI.parse("http://[v255.fe80::1]/")
end
it "should raise an error for " +
"'http://[v0.]/'" do
(lambda do
Addressable::URI.parse("http://[v0.]/")
end).should raise_error(Addressable::URI::InvalidURIError)
end
end
describe Addressable::URI, "when parsed from " +
"'http://example.com/'" do
before do
@uri = Addressable::URI.parse("http://example.com/")
end
# Based on http://intertwingly.net/blog/2004/07/31/URI-Equivalence
it "should be equivalent to http://example.com" do
@uri.should == Addressable::URI.parse("http://example.com")
end
# Based on http://intertwingly.net/blog/2004/07/31/URI-Equivalence
it "should be equivalent to HTTP://example.com/" do
@uri.should == Addressable::URI.parse("HTTP://example.com/")
end
# Based on http://intertwingly.net/blog/2004/07/31/URI-Equivalence
it "should be equivalent to http://example.com:/" do
@uri.should == Addressable::URI.parse("http://example.com:/")
end
# Based on http://intertwingly.net/blog/2004/07/31/URI-Equivalence
it "should be equivalent to http://example.com:80/" do
@uri.should == Addressable::URI.parse("http://example.com:80/")
end
# Based on http://intertwingly.net/blog/2004/07/31/URI-Equivalence
it "should be equivalent to http://Example.com/" do
@uri.should == Addressable::URI.parse("http://Example.com/")
end
it "should have the correct username after assignment" do
@uri.user = nil
@uri.user.should == nil
@uri.password.should == nil
@uri.to_s.should == "http://example.com/"
end
it "should have the correct password after assignment" do
@uri.password = nil
@uri.password.should == nil
@uri.user.should == nil
@uri.to_s.should == "http://example.com/"
end
it "should have a request URI of '/'" do
@uri.request_uri.should == "/"
end
it "should correctly convert to a hash" do
@uri.to_hash.should == {
:scheme => "http",
:user => nil,
:password => nil,
:host => "example.com",
:port => nil,
:path => "/",
:query => nil,
:fragment => nil
}
end
it "should be identical to its duplicate" do
@uri.should == @uri.dup
end
it "should have the same hash as its duplicate" do
@uri.hash.should == @uri.dup.hash
end
it "should have a different hash from its equivalent String value" do
@uri.hash.should_not == @uri.to_s.hash
end
it "should have the same hash as an equal URI" do
@uri.hash.should == Addressable::URI.parse("http://example.com/").hash
end
it "should be equivalent to http://EXAMPLE.com" do
@uri.should == Addressable::URI.parse("http://EXAMPLE.com")
end
it "should be equivalent to http://EXAMPLE.com:80/" do
@uri.should == Addressable::URI.parse("http://EXAMPLE.com:80/")
end
it "should have the same hash as http://example.com/" do
@uri.hash.should == Addressable::URI.parse("http://example.com/").hash
end
it "should have the same hash as http://example.com after assignment" do
@uri.path = ""
@uri.hash.should == Addressable::URI.parse("http://example.com").hash
end
it "should have the same hash as http://example.com/? after assignment" do
@uri.query = ""
@uri.hash.should == Addressable::URI.parse("http://example.com/?").hash
end
it "should have the same hash as http://example.com/? after assignment" do
@uri.query_values = {}
@uri.hash.should == Addressable::URI.parse("http://example.com/?").hash
end
it "should have the same hash as http://example.com/# after assignment" do
@uri.fragment = ""
@uri.hash.should == Addressable::URI.parse("http://example.com/#").hash
end
it "should have a different hash from http://example.com" do
@uri.hash.should_not == Addressable::URI.parse("http://example.com").hash
end
it "should have an origin of 'http://example.com'" do
@uri.origin.should == 'http://example.com'
end
end
describe Addressable::URI, "when parsed from " +
"'http://@example.com/'" do
before do
@uri = Addressable::URI.parse("http://@example.com/")
end
it "should be equivalent to http://example.com" do
@uri.should == Addressable::URI.parse("http://example.com")
end
it "should correctly convert to a hash" do
@uri.to_hash.should == {
:scheme => "http",
:user => "",
:password => nil,
:host => "example.com",
:port => nil,
:path => "/",
:query => nil,
:fragment => nil
}
end
it "should be identical to its duplicate" do
@uri.should == @uri.dup
end
it "should have an origin of 'http://example.com'" do
@uri.origin.should == 'http://example.com'
end
end
describe Addressable::URI, "when parsed from " +
"'http://example.com./'" do
before do
@uri = Addressable::URI.parse("http://example.com./")
end
it "should be equivalent to http://example.com" do
@uri.should == Addressable::URI.parse("http://example.com")
end
it "should not be considered to be in normal form" do
@uri.normalize.should_not be_eql(@uri)
end
it "should be identical to its duplicate" do
@uri.should == @uri.dup
end
it "should have an origin of 'http://example.com'" do
@uri.origin.should == 'http://example.com'
end
end
describe Addressable::URI, "when parsed from " +
"'http://:@example.com/'" do
before do
@uri = Addressable::URI.parse("http://:@example.com/")
end
it "should be equivalent to http://example.com" do
@uri.should == Addressable::URI.parse("http://example.com")
end
it "should correctly convert to a hash" do
@uri.to_hash.should == {
:scheme => "http",
:user => "",
:password => "",
:host => "example.com",
:port => nil,
:path => "/",
:query => nil,
:fragment => nil
}
end
it "should be identical to its duplicate" do
@uri.should == @uri.dup
end
it "should have an origin of 'http://example.com'" do
@uri.origin.should == 'http://example.com'
end
end
describe Addressable::URI, "when parsed from " +
"'http://example.com/~smith/'" do
before do
@uri = Addressable::URI.parse("http://example.com/~smith/")
end
# Based on http://intertwingly.net/blog/2004/07/31/URI-Equivalence
it "should be equivalent to http://example.com/%7Esmith/" do
@uri.should == Addressable::URI.parse("http://example.com/%7Esmith/")
end
# Based on http://intertwingly.net/blog/2004/07/31/URI-Equivalence
it "should be equivalent to http://example.com/%7esmith/" do
@uri.should == Addressable::URI.parse("http://example.com/%7esmith/")
end
it "should be identical to its duplicate" do
@uri.should == @uri.dup
end
end
describe Addressable::URI, "when parsed from " +
"'http://example.com/%E8'" do
before do
@uri = Addressable::URI.parse("http://example.com/%E8")
end
it "should not raise an exception when normalized" do
(lambda do
@uri.normalize
end).should_not raise_error(ArgumentError)
end
it "should be considered to be in normal form" do
@uri.normalize.should be_eql(@uri)
end
it "should not change if encoded with the normalizing algorithm" do
Addressable::URI.normalized_encode(@uri).to_s.should ==
"http://example.com/%E8"
Addressable::URI.normalized_encode(@uri, Addressable::URI).to_s.should ===
"http://example.com/%E8"
end
end
describe Addressable::URI, "when parsed from " +
"'http://example.com/path%2Fsegment/'" do
before do
@uri = Addressable::URI.parse("http://example.com/path%2Fsegment/")
end
it "should be considered to be in normal form" do
@uri.normalize.should be_eql(@uri)
end
it "should be equal to 'http://example.com/path%2Fsegment/'" do
@uri.normalize.should be_eql(
Addressable::URI.parse("http://example.com/path%2Fsegment/")
)
end
it "should not be equal to 'http://example.com/path/segment/'" do
@uri.should_not ==
Addressable::URI.parse("http://example.com/path/segment/")
end
it "should not be equal to 'http://example.com/path/segment/'" do
@uri.normalize.should_not be_eql(
Addressable::URI.parse("http://example.com/path/segment/")
)
end
end
describe Addressable::URI, "when parsed from " +
"'http://example.com/?%F6'" do
before do
@uri = Addressable::URI.parse("http://example.com/?%F6")
end
it "should not raise an exception when normalized" do
(lambda do
@uri.normalize
end).should_not raise_error(ArgumentError)
end
it "should be considered to be in normal form" do
@uri.normalize.should be_eql(@uri)
end
it "should not change if encoded with the normalizing algorithm" do
Addressable::URI.normalized_encode(@uri).to_s.should ==
"http://example.com/?%F6"
Addressable::URI.normalized_encode(@uri, Addressable::URI).to_s.should ===
"http://example.com/?%F6"
end
end
describe Addressable::URI, "when parsed from " +
"'http://example.com/#%F6'" do
before do
@uri = Addressable::URI.parse("http://example.com/#%F6")
end
it "should not raise an exception when normalized" do
(lambda do
@uri.normalize
end).should_not raise_error(ArgumentError)
end
it "should be considered to be in normal form" do
@uri.normalize.should be_eql(@uri)
end
it "should not change if encoded with the normalizing algorithm" do
Addressable::URI.normalized_encode(@uri).to_s.should ==
"http://example.com/#%F6"
Addressable::URI.normalized_encode(@uri, Addressable::URI).to_s.should ===
"http://example.com/#%F6"
end
end
describe Addressable::URI, "when parsed from " +
"'http://example.com/%C3%87'" do
before do
@uri = Addressable::URI.parse("http://example.com/%C3%87")
end
# Based on http://intertwingly.net/blog/2004/07/31/URI-Equivalence
it "should be equivalent to 'http://example.com/C%CC%A7'" do
@uri.should == Addressable::URI.parse("http://example.com/C%CC%A7")
end
it "should not change if encoded with the normalizing algorithm" do
Addressable::URI.normalized_encode(@uri).to_s.should ==
"http://example.com/%C3%87"
Addressable::URI.normalized_encode(@uri, Addressable::URI).to_s.should ===
"http://example.com/%C3%87"
end
it "should raise an error if encoding with an unexpected return type" do
(lambda do
Addressable::URI.normalized_encode(@uri, Integer)
end).should raise_error(TypeError)
end
it "if percent encoded should be 'http://example.com/C%25CC%25A7'" do
Addressable::URI.encode(@uri).to_s.should ==
"http://example.com/%25C3%2587"
end
it "if percent encoded should be 'http://example.com/C%25CC%25A7'" do
Addressable::URI.encode(@uri, Addressable::URI).should ==
Addressable::URI.parse("http://example.com/%25C3%2587")
end
it "should raise an error if encoding with an unexpected return type" do
(lambda do
Addressable::URI.encode(@uri, Integer)
end).should raise_error(TypeError)
end
it "should be identical to its duplicate" do
@uri.should == @uri.dup
end
end
describe Addressable::URI, "when parsed from " +
"'http://example.com/?q=string'" do
before do
@uri = Addressable::URI.parse("http://example.com/?q=string")
end
it "should use the 'http' scheme" do
@uri.scheme.should == "http"
end
it "should have an authority segment of 'example.com'" do
@uri.authority.should == "example.com"
end
it "should have a host of 'example.com'" do
@uri.host.should == "example.com"
end
it "should have no username" do
@uri.user.should == nil
end
it "should have no password" do
@uri.password.should == nil
end
it "should use port 80" do
@uri.inferred_port.should == 80
end
it "should have a path of '/'" do
@uri.path.should == "/"
end
it "should have a query string of 'q=string'" do
@uri.query.should == "q=string"
end
it "should have no fragment" do
@uri.fragment.should == nil
end
it "should be considered absolute" do
@uri.should be_absolute
end
it "should not be considered relative" do
@uri.should_not be_relative
end
it "should be considered to be in normal form" do
@uri.normalize.should be_eql(@uri)
end
it "should be identical to its duplicate" do
@uri.should == @uri.dup
end
end
describe Addressable::URI, "when parsed from " +
"'http://example.com:80/'" do
before do
@uri = Addressable::URI.parse("http://example.com:80/")
end
it "should use the 'http' scheme" do
@uri.scheme.should == "http"
end
it "should have an authority segment of 'example.com:80'" do
@uri.authority.should == "example.com:80"
end
it "should have a host of 'example.com'" do
@uri.host.should == "example.com"
end
it "should have no username" do
@uri.user.should == nil
end
it "should have no password" do
@uri.password.should == nil
end
it "should use port 80" do
@uri.inferred_port.should == 80
end
it "should have explicit port 80" do
@uri.port.should == 80
end
it "should have a path of '/'" do
@uri.path.should == "/"
end
it "should have no query string" do
@uri.query.should == nil
end
it "should have no fragment" do
@uri.fragment.should == nil
end
it "should be considered absolute" do
@uri.should be_absolute
end
it "should not be considered relative" do
@uri.should_not be_relative
end
it "should be exactly equal to http://example.com:80/" do
@uri.eql?(Addressable::URI.parse("http://example.com:80/")).should == true
end
it "should be roughly equal to http://example.com/" do
(@uri === Addressable::URI.parse("http://example.com/")).should == true
end
it "should be roughly equal to the string 'http://example.com/'" do
(@uri === "http://example.com/").should == true
end
it "should not be roughly equal to the string " +
"'http://example.com:bogus/'" do
(lambda do
(@uri === "http://example.com:bogus/").should == false
end).should_not raise_error
end
it "should result in itself when joined with itself" do
@uri.join(@uri).to_s.should == "http://example.com:80/"
@uri.join!(@uri).to_s.should == "http://example.com:80/"
end
# Section 6.2.3 of RFC 3986
it "should be equal to http://example.com/" do
@uri.should == Addressable::URI.parse("http://example.com/")
end
# Section 6.2.3 of RFC 3986
it "should be equal to http://example.com:/" do
@uri.should == Addressable::URI.parse("http://example.com:/")
end
# Section 6.2.3 of RFC 3986
it "should be equal to http://example.com:80/" do
@uri.should == Addressable::URI.parse("http://example.com:80/")
end
# Section 6.2.2.1 of RFC 3986
it "should be equal to http://EXAMPLE.COM/" do
@uri.should == Addressable::URI.parse("http://EXAMPLE.COM/")
end
it "should correctly convert to a hash" do
@uri.to_hash.should == {
:scheme => "http",
:user => nil,
:password => nil,
:host => "example.com",
:port => 80,
:path => "/",
:query => nil,
:fragment => nil
}
end
it "should be identical to its duplicate" do
@uri.should == @uri.dup
end
it "should have an origin of 'http://example.com'" do
@uri.origin.should == 'http://example.com'
end
it "should not change if encoded with the normalizing algorithm" do
Addressable::URI.normalized_encode(@uri).to_s.should ==
"http://example.com:80/"
Addressable::URI.normalized_encode(@uri, Addressable::URI).to_s.should ===
"http://example.com:80/"
end
end
describe Addressable::URI, "when parsed from " +
"'http://example.com:8080/'" do
before do
@uri = Addressable::URI.parse("http://example.com:8080/")
end
it "should use the 'http' scheme" do
@uri.scheme.should == "http"
end
it "should have an authority segment of 'example.com:8080'" do
@uri.authority.should == "example.com:8080"
end
it "should have a host of 'example.com'" do
@uri.host.should == "example.com"
end
it "should have no username" do
@uri.user.should == nil
end
it "should have no password" do
@uri.password.should == nil
end
it "should use port 8080" do
@uri.inferred_port.should == 8080
end
it "should have explicit port 8080" do
@uri.port.should == 8080
end
it "should have default port 80" do
@uri.default_port.should == 80
end
it "should have a path of '/'" do
@uri.path.should == "/"
end
it "should have no query string" do
@uri.query.should == nil
end
it "should have no fragment" do
@uri.fragment.should == nil
end
it "should be considered absolute" do
@uri.should be_absolute
end
it "should not be considered relative" do
@uri.should_not be_relative
end
it "should be exactly equal to http://example.com:8080/" do
@uri.eql?(Addressable::URI.parse(
"http://example.com:8080/")).should == true
end
it "should have a route of 'http://example.com:8080/' from " +
"'http://example.com/path/to/'" do
@uri.route_from("http://example.com/path/to/").should ==
Addressable::URI.parse("http://example.com:8080/")
end
it "should have a route of 'http://example.com:8080/' from " +
"'http://example.com:80/path/to/'" do
@uri.route_from("http://example.com:80/path/to/").should ==
Addressable::URI.parse("http://example.com:8080/")
end
it "should have a route of '/' from " +
"'http://example.com:8080/path/to/'" do
@uri.route_from("http://example.com:8080/path/to/").should ==
Addressable::URI.parse("/")
end
it "should have a route of 'http://example.com:8080/' from " +
"'http://user:pass@example.com/path/to/'" do
@uri.route_from("http://user:pass@example.com/path/to/").should ==
Addressable::URI.parse("http://example.com:8080/")
end
it "should correctly convert to a hash" do
@uri.to_hash.should == {
:scheme => "http",
:user => nil,
:password => nil,
:host => "example.com",
:port => 8080,
:path => "/",
:query => nil,
:fragment => nil
}
end
it "should be identical to its duplicate" do
@uri.should == @uri.dup
end
it "should have an origin of 'http://example.com:8080'" do
@uri.origin.should == 'http://example.com:8080'
end
it "should not change if encoded with the normalizing algorithm" do
Addressable::URI.normalized_encode(@uri).to_s.should ==
"http://example.com:8080/"
Addressable::URI.normalized_encode(@uri, Addressable::URI).to_s.should ===
"http://example.com:8080/"
end
end
describe Addressable::URI, "when parsed from " +
"'http://example.com:%38%30/'" do
before do
@uri = Addressable::URI.parse("http://example.com:%38%30/")
end
it "should have the correct port" do
@uri.port.should == 80
end
it "should not be considered to be in normal form" do
@uri.normalize.should_not be_eql(@uri)
end
it "should normalize to 'http://example.com/'" do
@uri.normalize.should === "http://example.com/"
end
it "should have an origin of 'http://example.com'" do
@uri.origin.should == 'http://example.com'
end
end
describe Addressable::URI, "when parsed from " +
"'http://example.com/..'" do
before do
@uri = Addressable::URI.parse("http://example.com/..")
end
it "should have the correct port" do
@uri.inferred_port.should == 80
end
it "should not be considered to be in normal form" do
@uri.normalize.should_not be_eql(@uri)
end
it "should normalize to 'http://example.com/'" do
@uri.normalize.should === "http://example.com/"
end
end
describe Addressable::URI, "when parsed from " +
"'http://example.com/../..'" do
before do
@uri = Addressable::URI.parse("http://example.com/../..")
end
it "should have the correct port" do
@uri.inferred_port.should == 80
end
it "should not be considered to be in normal form" do
@uri.normalize.should_not be_eql(@uri)
end
it "should normalize to 'http://example.com/'" do
@uri.normalize.should === "http://example.com/"
end
end
describe Addressable::URI, "when parsed from " +
"'http://example.com/path(/..'" do
before do
@uri = Addressable::URI.parse("http://example.com/path(/..")
end
it "should have the correct port" do
@uri.inferred_port.should == 80
end
it "should not be considered to be in normal form" do
@uri.normalize.should_not be_eql(@uri)
end
it "should normalize to 'http://example.com/'" do
@uri.normalize.should === "http://example.com/"
end
end
describe Addressable::URI, "when parsed from " +
"'http://example.com/(path)/..'" do
before do
@uri = Addressable::URI.parse("http://example.com/(path)/..")
end
it "should have the correct port" do
@uri.inferred_port.should == 80
end
it "should not be considered to be in normal form" do
@uri.normalize.should_not be_eql(@uri)
end
it "should normalize to 'http://example.com/'" do
@uri.normalize.should === "http://example.com/"
end
end
describe Addressable::URI, "when parsed from " +
"'http://example.com/path(/../'" do
before do
@uri = Addressable::URI.parse("http://example.com/path(/../")
end
it "should have the correct port" do
@uri.inferred_port.should == 80
end
it "should not be considered to be in normal form" do
@uri.normalize.should_not be_eql(@uri)
end
it "should normalize to 'http://example.com/'" do
@uri.normalize.should === "http://example.com/"
end
end
describe Addressable::URI, "when parsed from " +
"'http://example.com/(path)/../'" do
before do
@uri = Addressable::URI.parse("http://example.com/(path)/../")
end
it "should have the correct port" do
@uri.inferred_port.should == 80
end
it "should not be considered to be in normal form" do
@uri.normalize.should_not be_eql(@uri)
end
it "should normalize to 'http://example.com/'" do
@uri.normalize.should === "http://example.com/"
end
end
describe Addressable::URI, "when parsed from '/a/b/c/./../../g'" do
before do
@uri = Addressable::URI.parse("/a/b/c/./../../g")
end
it "should not be considered to be in normal form" do
@uri.normalize.should_not be_eql(@uri)
end
# Section 5.2.4 of RFC 3986
it "should normalize to '/a/g'" do
@uri.normalize.should === "/a/g"
end
end
describe Addressable::URI, "when parsed from 'mid/content=5/../6'" do
before do
@uri = Addressable::URI.parse("mid/content=5/../6")
end
it "should not be considered to be in normal form" do
@uri.normalize.should_not be_eql(@uri)
end
# Section 5.2.4 of RFC 3986
it "should normalize to 'mid/6'" do
@uri.normalize.should === "mid/6"
end
end
describe Addressable::URI, "when parsed from " +
"'http://www.example.com///../'" do
before do
@uri = Addressable::URI.parse('http://www.example.com///../')
end
it "should not be considered to be in normal form" do
@uri.normalize.should_not be_eql(@uri)
end
it "should normalize to 'http://www.example.com//'" do
@uri.normalize.should === "http://www.example.com//"
end
end
describe Addressable::URI, "when parsed from " +
"'http://example.com/path/to/resource/'" do
before do
@uri = Addressable::URI.parse("http://example.com/path/to/resource/")
end
it "should use the 'http' scheme" do
@uri.scheme.should == "http"
end
it "should have an authority segment of 'example.com'" do
@uri.authority.should == "example.com"
end
it "should have a host of 'example.com'" do
@uri.host.should == "example.com"
end
it "should have no username" do
@uri.user.should == nil
end
it "should have no password" do
@uri.password.should == nil
end
it "should use port 80" do
@uri.inferred_port.should == 80
end
it "should have a path of '/path/to/resource/'" do
@uri.path.should == "/path/to/resource/"
end
it "should have no query string" do
@uri.query.should == nil
end
it "should have no fragment" do
@uri.fragment.should == nil
end
it "should be considered absolute" do
@uri.should be_absolute
end
it "should not be considered relative" do
@uri.should_not be_relative
end
it "should be exactly equal to http://example.com:8080/" do
@uri.eql?(Addressable::URI.parse(
"http://example.com/path/to/resource/")).should == true
end
it "should have a route of 'resource/' from " +
"'http://example.com/path/to/'" do
@uri.route_from("http://example.com/path/to/").should ==
Addressable::URI.parse("resource/")
end
it "should have a route of 'resource/' from " +
"'http://example.com:80/path/to/'" do
@uri.route_from("http://example.com:80/path/to/").should ==
Addressable::URI.parse("resource/")
end
it "should have a route of 'http://example.com/path/to/' from " +
"'http://example.com:8080/path/to/'" do
@uri.route_from("http://example.com:8080/path/to/").should ==
Addressable::URI.parse("http://example.com/path/to/resource/")
end
it "should have a route of 'http://example.com/path/to/' from " +
"'http://user:pass@example.com/path/to/'" do
@uri.route_from("http://user:pass@example.com/path/to/").should ==
Addressable::URI.parse("http://example.com/path/to/resource/")
end
it "should have a route of '/path/to/resource/' from " +
"'http://example.com/to/resource/'" do
@uri.route_from("http://example.com/to/resource/").should ==
Addressable::URI.parse("/path/to/resource/")
end
it "should correctly convert to a hash" do
@uri.to_hash.should == {
:scheme => "http",
:user => nil,
:password => nil,
:host => "example.com",
:port => nil,
:path => "/path/to/resource/",
:query => nil,
:fragment => nil
}
end
it "should be identical to its duplicate" do
@uri.should == @uri.dup
end
end
describe Addressable::URI, "when parsed from " +
"'relative/path/to/resource'" do
before do
@uri = Addressable::URI.parse("relative/path/to/resource")
end
it "should not have a scheme" do
@uri.scheme.should == nil
end
it "should not be considered ip-based" do
@uri.should_not be_ip_based
end
it "should not have an authority segment" do
@uri.authority.should == nil
end
it "should not have a host" do
@uri.host.should == nil
end
it "should have no username" do
@uri.user.should == nil
end
it "should have no password" do
@uri.password.should == nil
end
it "should not have a port" do
@uri.port.should == nil
end
it "should have a path of 'relative/path/to/resource'" do
@uri.path.should == "relative/path/to/resource"
end
it "should have no query string" do
@uri.query.should == nil
end
it "should have no fragment" do
@uri.fragment.should == nil
end
it "should not be considered absolute" do
@uri.should_not be_absolute
end
it "should be considered relative" do
@uri.should be_relative
end
it "should raise an error if routing is attempted" do
(lambda do
@uri.route_to("http://example.com/")
end).should raise_error(ArgumentError, /relative\/path\/to\/resource/)
(lambda do
@uri.route_from("http://example.com/")
end).should raise_error(ArgumentError, /relative\/path\/to\/resource/)
end
it "when joined with 'another/relative/path' should be " +
"'relative/path/to/another/relative/path'" do
@uri.join('another/relative/path').should ==
Addressable::URI.parse("relative/path/to/another/relative/path")
end
it "should be identical to its duplicate" do
@uri.should == @uri.dup
end
end
describe Addressable::URI, "when parsed from " +
"'relative_path_with_no_slashes'" do
before do
@uri = Addressable::URI.parse("relative_path_with_no_slashes")
end
it "should not have a scheme" do
@uri.scheme.should == nil
end
it "should not be considered ip-based" do
@uri.should_not be_ip_based
end
it "should not have an authority segment" do
@uri.authority.should == nil
end
it "should not have a host" do
@uri.host.should == nil
end
it "should have no username" do
@uri.user.should == nil
end
it "should have no password" do
@uri.password.should == nil
end
it "should not have a port" do
@uri.port.should == nil
end
it "should have a path of 'relative_path_with_no_slashes'" do
@uri.path.should == "relative_path_with_no_slashes"
end
it "should have no query string" do
@uri.query.should == nil
end
it "should have no fragment" do
@uri.fragment.should == nil
end
it "should not be considered absolute" do
@uri.should_not be_absolute
end
it "should be considered relative" do
@uri.should be_relative
end
it "when joined with 'another_relative_path' should be " +
"'another_relative_path'" do
@uri.join('another_relative_path').should ==
Addressable::URI.parse("another_relative_path")
end
end
describe Addressable::URI, "when parsed from " +
"'http://example.com/file.txt'" do
before do
@uri = Addressable::URI.parse("http://example.com/file.txt")
end
it "should have a scheme of 'http'" do
@uri.scheme.should == "http"
end
it "should have an authority segment of 'example.com'" do
@uri.authority.should == "example.com"
end
it "should have a host of 'example.com'" do
@uri.host.should == "example.com"
end
it "should have no username" do
@uri.user.should == nil
end
it "should have no password" do
@uri.password.should == nil
end
it "should use port 80" do
@uri.inferred_port.should == 80
end
it "should have a path of '/file.txt'" do
@uri.path.should == "/file.txt"
end
it "should have a basename of 'file.txt'" do
@uri.basename.should == "file.txt"
end
it "should have an extname of '.txt'" do
@uri.extname.should == ".txt"
end
it "should have no query string" do
@uri.query.should == nil
end
it "should have no fragment" do
@uri.fragment.should == nil
end
end
describe Addressable::URI, "when parsed from " +
"'http://example.com/file.txt;parameter'" do
before do
@uri = Addressable::URI.parse("http://example.com/file.txt;parameter")
end
it "should have a scheme of 'http'" do
@uri.scheme.should == "http"
end
it "should have an authority segment of 'example.com'" do
@uri.authority.should == "example.com"
end
it "should have a host of 'example.com'" do
@uri.host.should == "example.com"
end
it "should have no username" do
@uri.user.should == nil
end
it "should have no password" do
@uri.password.should == nil
end
it "should use port 80" do
@uri.inferred_port.should == 80
end
it "should have a path of '/file.txt;parameter'" do
@uri.path.should == "/file.txt;parameter"
end
it "should have a basename of 'file.txt'" do
@uri.basename.should == "file.txt"
end
it "should have an extname of '.txt'" do
@uri.extname.should == ".txt"
end
it "should have no query string" do
@uri.query.should == nil
end
it "should have no fragment" do
@uri.fragment.should == nil
end
end
describe Addressable::URI, "when parsed from " +
"'http://example.com/file.txt;x=y'" do
before do
@uri = Addressable::URI.parse("http://example.com/file.txt;x=y")
end
it "should have a scheme of 'http'" do
@uri.scheme.should == "http"
end
it "should have a scheme of 'http'" do
@uri.scheme.should == "http"
end
it "should have an authority segment of 'example.com'" do
@uri.authority.should == "example.com"
end
it "should have a host of 'example.com'" do
@uri.host.should == "example.com"
end
it "should have no username" do
@uri.user.should == nil
end
it "should have no password" do
@uri.password.should == nil
end
it "should use port 80" do
@uri.inferred_port.should == 80
end
it "should have a path of '/file.txt;x=y'" do
@uri.path.should == "/file.txt;x=y"
end
it "should have an extname of '.txt'" do
@uri.extname.should == ".txt"
end
it "should have no query string" do
@uri.query.should == nil
end
it "should have no fragment" do
@uri.fragment.should == nil
end
it "should be considered to be in normal form" do
@uri.normalize.should be_eql(@uri)
end
end
describe Addressable::URI, "when parsed from " +
"'svn+ssh://developername@rubyforge.org/var/svn/project'" do
before do
@uri = Addressable::URI.parse(
"svn+ssh://developername@rubyforge.org/var/svn/project"
)
end
it "should have a scheme of 'svn+ssh'" do
@uri.scheme.should == "svn+ssh"
end
it "should be considered to be ip-based" do
@uri.should be_ip_based
end
it "should have a path of '/var/svn/project'" do
@uri.path.should == "/var/svn/project"
end
it "should have a username of 'developername'" do
@uri.user.should == "developername"
end
it "should have no password" do
@uri.password.should == nil
end
it "should be considered to be in normal form" do
@uri.normalize.should be_eql(@uri)
end
end
describe Addressable::URI, "when parsed from " +
"'ssh+svn://developername@RUBYFORGE.ORG/var/svn/project'" do
before do
@uri = Addressable::URI.parse(
"ssh+svn://developername@RUBYFORGE.ORG/var/svn/project"
)
end
it "should have a scheme of 'ssh+svn'" do
@uri.scheme.should == "ssh+svn"
end
it "should have a normalized scheme of 'svn+ssh'" do
@uri.normalized_scheme.should == "svn+ssh"
end
it "should have a normalized site of 'svn+ssh'" do
@uri.normalized_site.should == "svn+ssh://developername@rubyforge.org"
end
it "should not be considered to be ip-based" do
@uri.should_not be_ip_based
end
it "should have a path of '/var/svn/project'" do
@uri.path.should == "/var/svn/project"
end
it "should have a username of 'developername'" do
@uri.user.should == "developername"
end
it "should have no password" do
@uri.password.should == nil
end
it "should not be considered to be in normal form" do
@uri.normalize.should_not be_eql(@uri)
end
end
describe Addressable::URI, "when parsed from " +
"'mailto:user@example.com'" do
before do
@uri = Addressable::URI.parse("mailto:user@example.com")
end
it "should have a scheme of 'mailto'" do
@uri.scheme.should == "mailto"
end
it "should not be considered to be ip-based" do
@uri.should_not be_ip_based
end
it "should have a path of 'user@example.com'" do
@uri.path.should == "user@example.com"
end
it "should have no user" do
@uri.user.should == nil
end
it "should be considered to be in normal form" do
@uri.normalize.should be_eql(@uri)
end
end
describe Addressable::URI, "when parsed from " +
"'tag:example.com,2006-08-18:/path/to/something'" do
before do
@uri = Addressable::URI.parse(
"tag:example.com,2006-08-18:/path/to/something")
end
it "should have a scheme of 'tag'" do
@uri.scheme.should == "tag"
end
it "should be considered to be ip-based" do
@uri.should_not be_ip_based
end
it "should have a path of " +
"'example.com,2006-08-18:/path/to/something'" do
@uri.path.should == "example.com,2006-08-18:/path/to/something"
end
it "should have no user" do
@uri.user.should == nil
end
it "should be considered to be in normal form" do
@uri.normalize.should be_eql(@uri)
end
it "should have a 'null' origin" do
@uri.origin.should == 'null'
end
end
describe Addressable::URI, "when parsed from " +
"'http://example.com/x;y/'" do
before do
@uri = Addressable::URI.parse("http://example.com/x;y/")
end
it "should be considered to be in normal form" do
@uri.normalize.should be_eql(@uri)
end
end
describe Addressable::URI, "when parsed from " +
"'http://example.com/?x=1&y=2'" do
before do
@uri = Addressable::URI.parse("http://example.com/?x=1&y=2")
end
it "should be considered to be in normal form" do
@uri.normalize.should be_eql(@uri)
end
end
describe Addressable::URI, "when parsed from " +
"'view-source:http://example.com/'" do
before do
@uri = Addressable::URI.parse("view-source:http://example.com/")
end
it "should have a scheme of 'view-source'" do
@uri.scheme.should == "view-source"
end
it "should have a path of 'http://example.com/'" do
@uri.path.should == "http://example.com/"
end
it "should be considered to be in normal form" do
@uri.normalize.should be_eql(@uri)
end
it "should have a 'null' origin" do
@uri.origin.should == 'null'
end
end
describe Addressable::URI, "when parsed from " +
"'http://user:pass@example.com/path/to/resource?query=x#fragment'" do
before do
@uri = Addressable::URI.parse(
"http://user:pass@example.com/path/to/resource?query=x#fragment")
end
it "should use the 'http' scheme" do
@uri.scheme.should == "http"
end
it "should have an authority segment of 'user:pass@example.com'" do
@uri.authority.should == "user:pass@example.com"
end
it "should have a username of 'user'" do
@uri.user.should == "user"
end
it "should have a password of 'pass'" do
@uri.password.should == "pass"
end
it "should have a host of 'example.com'" do
@uri.host.should == "example.com"
end
it "should use port 80" do
@uri.inferred_port.should == 80
end
it "should have a path of '/path/to/resource'" do
@uri.path.should == "/path/to/resource"
end
it "should have a query string of 'query=x'" do
@uri.query.should == "query=x"
end
it "should have a fragment of 'fragment'" do
@uri.fragment.should == "fragment"
end
it "should be considered to be in normal form" do
@uri.normalize.should be_eql(@uri)
end
it "should have a route of '/path/' to " +
"'http://user:pass@example.com/path/'" do
@uri.route_to("http://user:pass@example.com/path/").should ==
Addressable::URI.parse("/path/")
end
it "should have a route of '/path/to/resource?query=x#fragment' " +
"from 'http://user:pass@example.com/path/'" do
@uri.route_from("http://user:pass@example.com/path/").should ==
Addressable::URI.parse("to/resource?query=x#fragment")
end
it "should have a route of '?query=x#fragment' " +
"from 'http://user:pass@example.com/path/to/resource'" do
@uri.route_from("http://user:pass@example.com/path/to/resource").should ==
Addressable::URI.parse("?query=x#fragment")
end
it "should have a route of '#fragment' " +
"from 'http://user:pass@example.com/path/to/resource?query=x'" do
@uri.route_from(
"http://user:pass@example.com/path/to/resource?query=x").should ==
Addressable::URI.parse("#fragment")
end
it "should have a route of '#fragment' from " +
"'http://user:pass@example.com/path/to/resource?query=x#fragment'" do
@uri.route_from(
"http://user:pass@example.com/path/to/resource?query=x#fragment"
).should == Addressable::URI.parse("#fragment")
end
it "should have a route of 'http://elsewhere.com/' to " +
"'http://elsewhere.com/'" do
@uri.route_to("http://elsewhere.com/").should ==
Addressable::URI.parse("http://elsewhere.com/")
end
it "should have a route of " +
"'http://user:pass@example.com/path/to/resource?query=x#fragment' " +
"from 'http://example.com/path/to/'" do
@uri.route_from("http://elsewhere.com/path/to/").should ==
Addressable::URI.parse(
"http://user:pass@example.com/path/to/resource?query=x#fragment")
end
it "should have the correct scheme after assignment" do
@uri.scheme = "ftp"
@uri.scheme.should == "ftp"
@uri.to_s.should ==
"ftp://user:pass@example.com/path/to/resource?query=x#fragment"
@uri.to_str.should ==
"ftp://user:pass@example.com/path/to/resource?query=x#fragment"
@uri.scheme = "bogus!"
@uri.scheme.should == "bogus!"
@uri.normalized_scheme.should == "bogus%21"
@uri.normalize.to_s.should ==
"bogus%21://user:pass@example.com/path/to/resource?query=x#fragment"
@uri.normalize.to_str.should ==
"bogus%21://user:pass@example.com/path/to/resource?query=x#fragment"
end
it "should have the correct site segment after assignment" do
@uri.site = "https://newuser:newpass@example.com:443"
@uri.scheme.should == "https"
@uri.authority.should == "newuser:newpass@example.com:443"
@uri.user.should == "newuser"
@uri.password.should == "newpass"
@uri.userinfo.should == "newuser:newpass"
@uri.normalized_userinfo.should == "newuser:newpass"
@uri.host.should == "example.com"
@uri.port.should == 443
@uri.inferred_port.should == 443
@uri.to_s.should ==
"https://newuser:newpass@example.com:443" +
"/path/to/resource?query=x#fragment"
end
it "should have the correct authority segment after assignment" do
@uri.authority = "newuser:newpass@example.com:80"
@uri.authority.should == "newuser:newpass@example.com:80"
@uri.user.should == "newuser"
@uri.password.should == "newpass"
@uri.userinfo.should == "newuser:newpass"
@uri.normalized_userinfo.should == "newuser:newpass"
@uri.host.should == "example.com"
@uri.port.should == 80
@uri.inferred_port.should == 80
@uri.to_s.should ==
"http://newuser:newpass@example.com:80" +
"/path/to/resource?query=x#fragment"
end
it "should have the correct userinfo segment after assignment" do
@uri.userinfo = "newuser:newpass"
@uri.userinfo.should == "newuser:newpass"
@uri.authority.should == "newuser:newpass@example.com"
@uri.user.should == "newuser"
@uri.password.should == "newpass"
@uri.host.should == "example.com"
@uri.port.should == nil
@uri.inferred_port.should == 80
@uri.to_s.should ==
"http://newuser:newpass@example.com" +
"/path/to/resource?query=x#fragment"
end
it "should have the correct username after assignment" do
@uri.user = "newuser"
@uri.user.should == "newuser"
@uri.authority.should == "newuser:pass@example.com"
end
it "should have the correct password after assignment" do
@uri.password = "newpass"
@uri.password.should == "newpass"
@uri.authority.should == "user:newpass@example.com"
end
it "should have the correct host after assignment" do
@uri.host = "newexample.com"
@uri.host.should == "newexample.com"
@uri.authority.should == "user:pass@newexample.com"
end
it "should have the correct port after assignment" do
@uri.port = 8080
@uri.port.should == 8080
@uri.authority.should == "user:pass@example.com:8080"
end
it "should have the correct path after assignment" do
@uri.path = "/newpath/to/resource"
@uri.path.should == "/newpath/to/resource"
@uri.to_s.should ==
"http://user:pass@example.com/newpath/to/resource?query=x#fragment"
end
it "should have the correct scheme and authority after nil assignment" do
@uri.site = nil
@uri.scheme.should == nil
@uri.authority.should == nil
@uri.to_s.should == "/path/to/resource?query=x#fragment"
end
it "should have the correct scheme and authority after assignment" do
@uri.site = "file://"
@uri.scheme.should == "file"
@uri.authority.should == ""
@uri.to_s.should == "file:///path/to/resource?query=x#fragment"
end
it "should have the correct path after nil assignment" do
@uri.path = nil
@uri.path.should == ""
@uri.to_s.should ==
"http://user:pass@example.com?query=x#fragment"
end
it "should have the correct query string after assignment" do
@uri.query = "newquery=x"
@uri.query.should == "newquery=x"
@uri.to_s.should ==
"http://user:pass@example.com/path/to/resource?newquery=x#fragment"
@uri.query = nil
@uri.query.should == nil
@uri.to_s.should ==
"http://user:pass@example.com/path/to/resource#fragment"
end
it "should have the correct query string after hash assignment" do
@uri.query_values = {"?uestion mark" => "=sign", "hello" => "g\xC3\xBCnther"}
@uri.query.split("&").should include("%3Fuestion%20mark=%3Dsign")
@uri.query.split("&").should include("hello=g%C3%BCnther")
@uri.query_values.should == {
"?uestion mark" => "=sign", "hello" => "g\xC3\xBCnther"
}
end
it "should have the correct query string after flag hash assignment" do
@uri.query_values = {'flag?1' => nil, 'fl=ag2' => nil, 'flag3' => nil}
@uri.query.split("&").should include("flag%3F1")
@uri.query.split("&").should include("fl%3Dag2")
@uri.query.split("&").should include("flag3")
@uri.query_values(Array).sort.should == [["fl=ag2"], ["flag3"], ["flag?1"]]
@uri.query_values(Hash).should == {
'flag?1' => nil, 'fl=ag2' => nil, 'flag3' => nil
}
end
it "should raise an error if query values are set to a bogus type" do
(lambda do
@uri.query_values = "bogus"
end).should raise_error(TypeError)
end
it "should have the correct fragment after assignment" do
@uri.fragment = "newfragment"
@uri.fragment.should == "newfragment"
@uri.to_s.should ==
"http://user:pass@example.com/path/to/resource?query=x#newfragment"
@uri.fragment = nil
@uri.fragment.should == nil
@uri.to_s.should ==
"http://user:pass@example.com/path/to/resource?query=x"
end
it "should have the correct values after a merge" do
@uri.merge(:fragment => "newfragment").to_s.should ==
"http://user:pass@example.com/path/to/resource?query=x#newfragment"
end
it "should have the correct values after a merge" do
@uri.merge(:fragment => nil).to_s.should ==
"http://user:pass@example.com/path/to/resource?query=x"
end
it "should have the correct values after a merge" do
@uri.merge(:userinfo => "newuser:newpass").to_s.should ==
"http://newuser:newpass@example.com/path/to/resource?query=x#fragment"
end
it "should have the correct values after a merge" do
@uri.merge(:userinfo => nil).to_s.should ==
"http://example.com/path/to/resource?query=x#fragment"
end
it "should have the correct values after a merge" do
@uri.merge(:path => "newpath").to_s.should ==
"http://user:pass@example.com/newpath?query=x#fragment"
end
it "should have the correct values after a merge" do
@uri.merge(:port => "42", :path => "newpath", :query => "").to_s.should ==
"http://user:pass@example.com:42/newpath?#fragment"
end
it "should have the correct values after a merge" do
@uri.merge(:authority => "foo:bar@baz:42").to_s.should ==
"http://foo:bar@baz:42/path/to/resource?query=x#fragment"
# Ensure the operation was not destructive
@uri.to_s.should ==
"http://user:pass@example.com/path/to/resource?query=x#fragment"
end
it "should have the correct values after a destructive merge" do
@uri.merge!(:authority => "foo:bar@baz:42")
# Ensure the operation was destructive
@uri.to_s.should ==
"http://foo:bar@baz:42/path/to/resource?query=x#fragment"
end
it "should fail to merge with bogus values" do
(lambda do
@uri.merge(:port => "bogus")
end).should raise_error(Addressable::URI::InvalidURIError)
end
it "should fail to merge with bogus values" do
(lambda do
@uri.merge(:authority => "bar@baz:bogus")
end).should raise_error(Addressable::URI::InvalidURIError)
end
it "should fail to merge with bogus parameters" do
(lambda do
@uri.merge(42)
end).should raise_error(TypeError)
end
it "should fail to merge with bogus parameters" do
(lambda do
@uri.merge("http://example.com/")
end).should raise_error(TypeError)
end
it "should fail to merge with both authority and subcomponents" do
(lambda do
@uri.merge(:authority => "foo:bar@baz:42", :port => "42")
end).should raise_error(ArgumentError)
end
it "should fail to merge with both userinfo and subcomponents" do
(lambda do
@uri.merge(:userinfo => "foo:bar", :user => "foo")
end).should raise_error(ArgumentError)
end
it "should be identical to its duplicate" do
@uri.should == @uri.dup
end
it "should have an origin of 'http://example.com'" do
@uri.origin.should == 'http://example.com'
end
end
describe Addressable::URI, "when parsed from " +
"'http://example.com/search?q=Q%26A'" do
before do
@uri = Addressable::URI.parse("http://example.com/search?q=Q%26A")
end
it "should have a query of 'q=Q%26A'" do
@uri.query.should == "q=Q%26A"
end
it "should have query_values of {'q' => 'Q&A'}" do
@uri.query_values.should == { 'q' => 'Q&A' }
end
it "should normalize to the original uri " +
"(with the ampersand properly percent-encoded)" do
@uri.normalize.to_s.should == "http://example.com/search?q=Q%26A"
end
end
describe Addressable::URI, "when parsed from " +
"'http://example.com/?&x=b'" do
before do
@uri = Addressable::URI.parse("http://example.com/?&x=b")
end
it "should have a query of '&x=b'" do
@uri.query.should == "&x=b"
end
it "should have query_values of {'x' => 'b'}" do
@uri.query_values.should == {'x' => 'b'}
end
end
describe Addressable::URI, "when parsed from " +
"'http://example.com/?q='one;two'&x=1'" do
before do
@uri = Addressable::URI.parse("http://example.com/?q='one;two'&x=1")
end
it "should have a query of 'q='one;two'&x=1'" do
@uri.query.should == "q='one;two'&x=1"
end
it "should have query_values of {\"q\" => \"'one;two'\", \"x\" => \"1\"}" do
@uri.query_values.should == {"q" => "'one;two'", "x" => "1"}
end
it "should escape the ';' character when normalizing to avoid ambiguity " +
"with the W3C HTML 4.01 specification" do
# HTML 4.01 Section B.2.2
@uri.normalize.query.should == "q='one%3Btwo'&x=1"
end
end
describe Addressable::URI, "when parsed from " +
"'http://example.com/?&&x=b'" do
before do
@uri = Addressable::URI.parse("http://example.com/?&&x=b")
end
it "should have a query of '&&x=b'" do
@uri.query.should == "&&x=b"
end
it "should have query_values of {'x' => 'b'}" do
@uri.query_values.should == {'x' => 'b'}
end
end
describe Addressable::URI, "when parsed from " +
"'http://example.com/?q=a&&x=b'" do
before do
@uri = Addressable::URI.parse("http://example.com/?q=a&&x=b")
end
it "should have a query of 'q=a&&x=b'" do
@uri.query.should == "q=a&&x=b"
end
it "should have query_values of {'q' => 'a, 'x' => 'b'}" do
@uri.query_values.should == {'q' => 'a', 'x' => 'b'}
end
end
describe Addressable::URI, "when parsed from " +
"'http://example.com/?q&&x=b'" do
before do
@uri = Addressable::URI.parse("http://example.com/?q&&x=b")
end
it "should have a query of 'q&&x=b'" do
@uri.query.should == "q&&x=b"
end
it "should have query_values of {'q' => true, 'x' => 'b'}" do
@uri.query_values.should == {'q' => nil, 'x' => 'b'}
end
end
describe Addressable::URI, "when parsed from " +
"'http://example.com/?q=a+b'" do
before do
@uri = Addressable::URI.parse("http://example.com/?q=a+b")
end
it "should have a query of 'q=a+b'" do
@uri.query.should == "q=a+b"
end
it "should have query_values of {'q' => 'a b'}" do
@uri.query_values.should == {'q' => 'a b'}
end
it "should have a normalized query of 'q=a+b'" do
@uri.normalized_query.should == "q=a+b"
end
end
describe Addressable::URI, "when parsed from " +
"'http://example.com/?q=a%2bb'" do
before do
@uri = Addressable::URI.parse("http://example.com/?q=a%2bb")
end
it "should have a query of 'q=a+b'" do
@uri.query.should == "q=a%2bb"
end
it "should have query_values of {'q' => 'a+b'}" do
@uri.query_values.should == {'q' => 'a+b'}
end
it "should have a normalized query of 'q=a%2Bb'" do
@uri.normalized_query.should == "q=a%2Bb"
end
end
describe Addressable::URI, "when parsed from " +
"'http://example.com/?v=%7E&w=%&x=%25&y=%2B&z=C%CC%A7'" do
before do
@uri = Addressable::URI.parse("http://example.com/?v=%7E&w=%&x=%25&y=%2B&z=C%CC%A7")
end
it "should have a normalized query of 'v=~&w=%25&x=%25&y=%2B&z=%C3%87'" do
@uri.normalized_query.should == "v=~&w=%25&x=%25&y=%2B&z=%C3%87"
end
end
describe Addressable::URI, "when parsed from " +
"'http://example.com/?v=%7E&w=%&x=%25&y=+&z=C%CC%A7'" do
before do
@uri = Addressable::URI.parse("http://example.com/?v=%7E&w=%&x=%25&y=+&z=C%CC%A7")
end
it "should have a normalized query of 'v=~&w=%25&x=%25&y=+&z=%C3%87'" do
@uri.normalized_query.should == "v=~&w=%25&x=%25&y=+&z=%C3%87"
end
end
describe Addressable::URI, "when parsed from " +
"'http://example.com/sound%2bvision'" do
before do
@uri = Addressable::URI.parse("http://example.com/sound%2bvision")
end
it "should have a normalized path of '/sound+vision'" do
@uri.normalized_path.should == '/sound+vision'
end
end
describe Addressable::URI, "when parsed from " +
"'http://example.com/?q='" do
before do
@uri = Addressable::URI.parse("http://example.com/?q=")
end
it "should have a query of 'q='" do
@uri.query.should == "q="
end
it "should have query_values of {'q' => ''}" do
@uri.query_values.should == {'q' => ''}
end
end
describe Addressable::URI, "when parsed from " +
"'http://user@example.com'" do
before do
@uri = Addressable::URI.parse("http://user@example.com")
end
it "should use the 'http' scheme" do
@uri.scheme.should == "http"
end
it "should have a username of 'user'" do
@uri.user.should == "user"
end
it "should have no password" do
@uri.password.should == nil
end
it "should have a userinfo of 'user'" do
@uri.userinfo.should == "user"
end
it "should have a normalized userinfo of 'user'" do
@uri.normalized_userinfo.should == "user"
end
it "should have a host of 'example.com'" do
@uri.host.should == "example.com"
end
it "should have default_port 80" do
@uri.default_port.should == 80
end
it "should use port 80" do
@uri.inferred_port.should == 80
end
it "should have the correct username after assignment" do
@uri.user = "newuser"
@uri.user.should == "newuser"
@uri.password.should == nil
@uri.to_s.should == "http://newuser@example.com"
end
it "should have the correct password after assignment" do
@uri.password = "newpass"
@uri.password.should == "newpass"
@uri.to_s.should == "http://user:newpass@example.com"
end
it "should have the correct userinfo segment after assignment" do
@uri.userinfo = "newuser:newpass"
@uri.userinfo.should == "newuser:newpass"
@uri.user.should == "newuser"
@uri.password.should == "newpass"
@uri.host.should == "example.com"
@uri.port.should == nil
@uri.inferred_port.should == 80
@uri.to_s.should == "http://newuser:newpass@example.com"
end
it "should have the correct userinfo segment after nil assignment" do
@uri.userinfo = nil
@uri.userinfo.should == nil
@uri.user.should == nil
@uri.password.should == nil
@uri.host.should == "example.com"
@uri.port.should == nil
@uri.inferred_port.should == 80
@uri.to_s.should == "http://example.com"
end
it "should have the correct authority segment after assignment" do
@uri.authority = "newuser@example.com"
@uri.authority.should == "newuser@example.com"
@uri.user.should == "newuser"
@uri.password.should == nil
@uri.host.should == "example.com"
@uri.port.should == nil
@uri.inferred_port.should == 80
@uri.to_s.should == "http://newuser@example.com"
end
it "should raise an error after nil assignment of authority segment" do
(lambda do
# This would create an invalid URI
@uri.authority = nil
end).should raise_error
end
end
describe Addressable::URI, "when parsed from " +
"'http://user:@example.com'" do
before do
@uri = Addressable::URI.parse("http://user:@example.com")
end
it "should use the 'http' scheme" do
@uri.scheme.should == "http"
end
it "should have a username of 'user'" do
@uri.user.should == "user"
end
it "should have a password of ''" do
@uri.password.should == ""
end
it "should have a normalized userinfo of 'user:'" do
@uri.normalized_userinfo.should == "user:"
end
it "should have a host of 'example.com'" do
@uri.host.should == "example.com"
end
it "should use port 80" do
@uri.inferred_port.should == 80
end
it "should have the correct username after assignment" do
@uri.user = "newuser"
@uri.user.should == "newuser"
@uri.password.should == ""
@uri.to_s.should == "http://newuser:@example.com"
end
it "should have the correct password after assignment" do
@uri.password = "newpass"
@uri.password.should == "newpass"
@uri.to_s.should == "http://user:newpass@example.com"
end
it "should have the correct authority segment after assignment" do
@uri.authority = "newuser:@example.com"
@uri.authority.should == "newuser:@example.com"
@uri.user.should == "newuser"
@uri.password.should == ""
@uri.host.should == "example.com"
@uri.port.should == nil
@uri.inferred_port.should == 80
@uri.to_s.should == "http://newuser:@example.com"
end
end
describe Addressable::URI, "when parsed from " +
"'http://:pass@example.com'" do
before do
@uri = Addressable::URI.parse("http://:pass@example.com")
end
it "should use the 'http' scheme" do
@uri.scheme.should == "http"
end
it "should have a username of ''" do
@uri.user.should == ""
end
it "should have a password of 'pass'" do
@uri.password.should == "pass"
end
it "should have a userinfo of ':pass'" do
@uri.userinfo.should == ":pass"
end
it "should have a normalized userinfo of ':pass'" do
@uri.normalized_userinfo.should == ":pass"
end
it "should have a host of 'example.com'" do
@uri.host.should == "example.com"
end
it "should use port 80" do
@uri.inferred_port.should == 80
end
it "should have the correct username after assignment" do
@uri.user = "newuser"
@uri.user.should == "newuser"
@uri.password.should == "pass"
@uri.to_s.should == "http://newuser:pass@example.com"
end
it "should have the correct password after assignment" do
@uri.password = "newpass"
@uri.password.should == "newpass"
@uri.user.should == ""
@uri.to_s.should == "http://:newpass@example.com"
end
it "should have the correct authority segment after assignment" do
@uri.authority = ":newpass@example.com"
@uri.authority.should == ":newpass@example.com"
@uri.user.should == ""
@uri.password.should == "newpass"
@uri.host.should == "example.com"
@uri.port.should == nil
@uri.inferred_port.should == 80
@uri.to_s.should == "http://:newpass@example.com"
end
end
describe Addressable::URI, "when parsed from " +
"'http://:@example.com'" do
before do
@uri = Addressable::URI.parse("http://:@example.com")
end
it "should use the 'http' scheme" do
@uri.scheme.should == "http"
end
it "should have a username of ''" do
@uri.user.should == ""
end
it "should have a password of ''" do
@uri.password.should == ""
end
it "should have a normalized userinfo of nil" do
@uri.normalized_userinfo.should == nil
end
it "should have a host of 'example.com'" do
@uri.host.should == "example.com"
end
it "should use port 80" do
@uri.inferred_port.should == 80
end
it "should have the correct username after assignment" do
@uri.user = "newuser"
@uri.user.should == "newuser"
@uri.password.should == ""
@uri.to_s.should == "http://newuser:@example.com"
end
it "should have the correct password after assignment" do
@uri.password = "newpass"
@uri.password.should == "newpass"
@uri.user.should == ""
@uri.to_s.should == "http://:newpass@example.com"
end
it "should have the correct authority segment after assignment" do
@uri.authority = ":@newexample.com"
@uri.authority.should == ":@newexample.com"
@uri.user.should == ""
@uri.password.should == ""
@uri.host.should == "newexample.com"
@uri.port.should == nil
@uri.inferred_port.should == 80
@uri.to_s.should == "http://:@newexample.com"
end
end
describe Addressable::URI, "when parsed from " +
"'#example'" do
before do
@uri = Addressable::URI.parse("#example")
end
it "should be considered relative" do
@uri.should be_relative
end
it "should have a host of nil" do
@uri.host.should == nil
end
it "should have a site of nil" do
@uri.site.should == nil
end
it "should have a normalized_site of nil" do
@uri.normalized_site.should == nil
end
it "should have a path of ''" do
@uri.path.should == ""
end
it "should have a query string of nil" do
@uri.query.should == nil
end
it "should have a fragment of 'example'" do
@uri.fragment.should == "example"
end
end
describe Addressable::URI, "when parsed from " +
"the network-path reference '//example.com/'" do
before do
@uri = Addressable::URI.parse("//example.com/")
end
it "should be considered relative" do
@uri.should be_relative
end
it "should have a host of 'example.com'" do
@uri.host.should == "example.com"
end
it "should have a path of '/'" do
@uri.path.should == "/"
end
it "should raise an error if routing is attempted" do
(lambda do
@uri.route_to("http://example.com/")
end).should raise_error(ArgumentError, /\/\/example.com\//)
(lambda do
@uri.route_from("http://example.com/")
end).should raise_error(ArgumentError, /\/\/example.com\//)
end
it "should have a 'null' origin" do
@uri.origin.should == 'null'
end
end
describe Addressable::URI, "when parsed from " +
"'feed://http://example.com/'" do
before do
@uri = Addressable::URI.parse("feed://http://example.com/")
end
it "should have a host of 'http'" do
@uri.host.should == "http"
end
it "should have a path of '//example.com/'" do
@uri.path.should == "//example.com/"
end
end
describe Addressable::URI, "when parsed from " +
"'feed:http://example.com/'" do
before do
@uri = Addressable::URI.parse("feed:http://example.com/")
end
it "should have a path of 'http://example.com/'" do
@uri.path.should == "http://example.com/"
end
it "should normalize to 'http://example.com/'" do
@uri.normalize.to_s.should == "http://example.com/"
@uri.normalize!.to_s.should == "http://example.com/"
end
it "should have a 'null' origin" do
@uri.origin.should == 'null'
end
end
describe Addressable::URI, "when parsed from " +
"'example://a/b/c/%7Bfoo%7D'" do
before do
@uri = Addressable::URI.parse("example://a/b/c/%7Bfoo%7D")
end
# Section 6.2.2 of RFC 3986
it "should be equivalent to eXAMPLE://a/./b/../b/%63/%7bfoo%7d" do
@uri.should ==
Addressable::URI.parse("eXAMPLE://a/./b/../b/%63/%7bfoo%7d")
end
it "should have an origin of 'example://a'" do
@uri.origin.should == 'example://a'
end
end
describe Addressable::URI, "when parsed from " +
"'http://example.com/indirect/path/./to/../resource/'" do
before do
@uri = Addressable::URI.parse(
"http://example.com/indirect/path/./to/../resource/")
end
it "should use the 'http' scheme" do
@uri.scheme.should == "http"
end
it "should have a host of 'example.com'" do
@uri.host.should == "example.com"
end
it "should use port 80" do
@uri.inferred_port.should == 80
end
it "should have a path of '/indirect/path/./to/../resource/'" do
@uri.path.should == "/indirect/path/./to/../resource/"
end
# Section 6.2.2.3 of RFC 3986
it "should have a normalized path of '/indirect/path/resource/'" do
@uri.normalize.path.should == "/indirect/path/resource/"
@uri.normalize!.path.should == "/indirect/path/resource/"
end
end
describe Addressable::URI, "when parsed from " +
"'http://under_score.example.com/'" do
it "should not cause an error" do
(lambda do
Addressable::URI.parse("http://under_score.example.com/")
end).should_not raise_error
end
end
describe Addressable::URI, "when parsed from " +
"'./this:that'" do
before do
@uri = Addressable::URI.parse("./this:that")
end
it "should be considered relative" do
@uri.should be_relative
end
it "should have no scheme" do
@uri.scheme.should == nil
end
it "should have a 'null' origin" do
@uri.origin.should == 'null'
end
end
describe Addressable::URI, "when parsed from " +
"'this:that'" do
before do
@uri = Addressable::URI.parse("this:that")
end
it "should be considered absolute" do
@uri.should be_absolute
end
it "should have a scheme of 'this'" do
@uri.scheme.should == "this"
end
it "should have a 'null' origin" do
@uri.origin.should == 'null'
end
end
describe Addressable::URI, "when parsed from '?'" do
before do
@uri = Addressable::URI.parse("?")
end
it "should have the correct return type" do
@uri.query_values.should == {}
@uri.query_values(Hash).should == {}
@uri.query_values(Array).should == []
end
it "should have a 'null' origin" do
@uri.origin.should == 'null'
end
end
describe Addressable::URI, "when parsed from '?one=1&two=2&three=3'" do
before do
@uri = Addressable::URI.parse("?one=1&two=2&three=3")
end
it "should have the correct query values" do
@uri.query_values.should == {"one" => "1", "two" => "2", "three" => "3"}
end
it "should raise an error for invalid return type values" do
(lambda do
@uri.query_values(Fixnum)
end).should raise_error(ArgumentError)
end
it "should have the correct array query values" do
@uri.query_values(Array).should == [
["one", "1"], ["two", "2"], ["three", "3"]
]
end
it "should have a 'null' origin" do
@uri.origin.should == 'null'
end
end
describe Addressable::URI, "when parsed from '?one=1=uno&two=2=dos'" do
before do
@uri = Addressable::URI.parse("?one=1=uno&two=2=dos")
end
it "should have the correct query values" do
@uri.query_values.should == {"one" => "1=uno", "two" => "2=dos"}
end
it "should have the correct array query values" do
@uri.query_values(Array).should == [
["one", "1=uno"], ["two", "2=dos"]
]
end
end
describe Addressable::URI, "when parsed from '?one[two][three]=four'" do
before do
@uri = Addressable::URI.parse("?one[two][three]=four")
end
it "should have the correct query values" do
@uri.query_values.should == {"one[two][three]" => "four"}
end
it "should have the correct array query values" do
@uri.query_values(Array).should == [
["one[two][three]", "four"]
]
end
end
describe Addressable::URI, "when parsed from '?one.two.three=four'" do
before do
@uri = Addressable::URI.parse("?one.two.three=four")
end
it "should have the correct query values" do
@uri.query_values.should == {
"one.two.three" => "four"
}
end
it "should have the correct array query values" do
@uri.query_values(Array).should == [
["one.two.three", "four"]
]
end
end
describe Addressable::URI, "when parsed from " +
"'?one[two][three]=four&one[two][five]=six'" do
before do
@uri = Addressable::URI.parse("?one[two][three]=four&one[two][five]=six")
end
it "should have the correct query values" do
@uri.query_values.should == {
"one[two][three]" => "four", "one[two][five]" => "six"
}
end
it "should have the correct array query values" do
@uri.query_values(Array).should == [
["one[two][three]", "four"], ["one[two][five]", "six"]
]
end
end
describe Addressable::URI, "when parsed from " +
"'?one.two.three=four&one.two.five=six'" do
before do
@uri = Addressable::URI.parse("?one.two.three=four&one.two.five=six")
end
it "should have the correct query values" do
@uri.query_values.should == {
"one.two.three" => "four", "one.two.five" => "six"
}
end
it "should have the correct array query values" do
@uri.query_values(Array).should == [
["one.two.three", "four"], ["one.two.five", "six"]
]
end
end
describe Addressable::URI, "when parsed from " +
"'?one=two&one=three'" do
before do
@uri = Addressable::URI.parse(
"?one=two&one=three&one=four"
)
end
it "should have correct array query values" do
@uri.query_values(Array).should ==
[['one', 'two'], ['one', 'three'], ['one', 'four']]
end
it "should have correct hash query values" do
pending("This is probably more desirable behavior.") do
@uri.query_values(Hash).should ==
{'one' => ['two', 'three', 'four']}
end
end
end
describe Addressable::URI, "when parsed from " +
"'?one[two][three][]=four&one[two][three][]=five'" do
before do
@uri = Addressable::URI.parse(
"?one[two][three][]=four&one[two][three][]=five"
)
end
it "should have correct query values" do
@uri.query_values(Hash).should == {"one[two][three][]" => "five"}
end
it "should have correct array query values" do
@uri.query_values(Array).should == [
["one[two][three][]", "four"], ["one[two][three][]", "five"]
]
end
end
describe Addressable::URI, "when parsed from " +
"'?one[two][three][0]=four&one[two][three][1]=five'" do
before do
@uri = Addressable::URI.parse(
"?one[two][three][0]=four&one[two][three][1]=five"
)
end
it "should have the correct query values" do
@uri.query_values.should == {
"one[two][three][0]" => "four", "one[two][three][1]" => "five"
}
end
end
describe Addressable::URI, "when parsed from " +
"'?one[two][three][1]=four&one[two][three][0]=five'" do
before do
@uri = Addressable::URI.parse(
"?one[two][three][1]=four&one[two][three][0]=five"
)
end
it "should have the correct query values" do
@uri.query_values.should == {
"one[two][three][1]" => "four", "one[two][three][0]" => "five"
}
end
end
describe Addressable::URI, "when parsed from " +
"'?one[two][three][2]=four&one[two][three][1]=five'" do
before do
@uri = Addressable::URI.parse(
"?one[two][three][2]=four&one[two][three][1]=five"
)
end
it "should have the correct query values" do
@uri.query_values.should == {
"one[two][three][2]" => "four", "one[two][three][1]" => "five"
}
end
end
describe Addressable::URI, "when parsed from " +
"'http://www.詹姆斯.com/'" do
before do
@uri = Addressable::URI.parse("http://www.詹姆斯.com/")
end
it "should be equivalent to 'http://www.xn--8ws00zhy3a.com/'" do
@uri.should ==
Addressable::URI.parse("http://www.xn--8ws00zhy3a.com/")
end
it "should not have domain name encoded during normalization" do
Addressable::URI.normalized_encode(@uri.to_s).should ==
"http://www.詹姆斯.com/"
end
it "should have an origin of 'http://www.xn--8ws00zhy3a.com'" do
@uri.origin.should == 'http://www.xn--8ws00zhy3a.com'
end
end
describe Addressable::URI, "when parsed from " +
"'http://www.詹姆斯.com/ some spaces /'" do
before do
@uri = Addressable::URI.parse("http://www.詹姆斯.com/ some spaces /")
end
it "should be equivalent to " +
"'http://www.xn--8ws00zhy3a.com/%20some%20spaces%20/'" do
@uri.should ==
Addressable::URI.parse(
"http://www.xn--8ws00zhy3a.com/%20some%20spaces%20/")
end
it "should not have domain name encoded during normalization" do
Addressable::URI.normalized_encode(@uri.to_s).should ==
"http://www.詹姆斯.com/%20some%20spaces%20/"
end
it "should have an origin of 'http://www.xn--8ws00zhy3a.com'" do
@uri.origin.should == 'http://www.xn--8ws00zhy3a.com'
end
end
describe Addressable::URI, "when parsed from " +
"'http://www.xn--8ws00zhy3a.com/'" do
before do
@uri = Addressable::URI.parse("http://www.xn--8ws00zhy3a.com/")
end
it "should be displayed as http://www.詹姆斯.com/" do
@uri.display_uri.to_s.should == "http://www.詹姆斯.com/"
end
it "should properly force the encoding" do
display_string = @uri.display_uri.to_str
display_string.should == "http://www.詹姆斯.com/"
if display_string.respond_to?(:encoding)
display_string.encoding.to_s.should == Encoding::UTF_8.to_s
end
end
it "should have an origin of 'http://www.xn--8ws00zhy3a.com'" do
@uri.origin.should == 'http://www.xn--8ws00zhy3a.com'
end
end
describe Addressable::URI, "when parsed from " +
"'http://www.詹姆斯.com/atomtests/iri/詹.html'" do
before do
@uri = Addressable::URI.parse("http://www.詹姆斯.com/atomtests/iri/詹.html")
end
it "should normalize to " +
"http://www.xn--8ws00zhy3a.com/atomtests/iri/%E8%A9%B9.html" do
@uri.normalize.to_s.should ==
"http://www.xn--8ws00zhy3a.com/atomtests/iri/%E8%A9%B9.html"
@uri.normalize!.to_s.should ==
"http://www.xn--8ws00zhy3a.com/atomtests/iri/%E8%A9%B9.html"
end
end
describe Addressable::URI, "when parsed from a percent-encoded IRI" do
before do
@uri = Addressable::URI.parse(
"http://www.%E3%81%BB%E3%82%93%E3%81%A8%E3%81%86%E3%81%AB%E3%81%AA" +
"%E3%81%8C%E3%81%84%E3%82%8F%E3%81%91%E3%81%AE%E3%82%8F%E3%81%8B%E3" +
"%82%89%E3%81%AA%E3%81%84%E3%81%A9%E3%82%81%E3%81%84%E3%82%93%E3%82" +
"%81%E3%81%84%E3%81%AE%E3%82%89%E3%81%B9%E3%82%8B%E3%81%BE%E3%81%A0" +
"%E3%81%AA%E3%81%8C%E3%81%8F%E3%81%97%E3%81%AA%E3%81%84%E3%81%A8%E3" +
"%81%9F%E3%82%8A%E3%81%AA%E3%81%84.w3.mag.keio.ac.jp"
)
end
it "should normalize to something sane" do
@uri.normalize.to_s.should ==
"http://www.xn--n8jaaaaai5bhf7as8fsfk3jnknefdde3f" +
"g11amb5gzdb4wi9bya3kc6lra.w3.mag.keio.ac.jp/"
@uri.normalize!.to_s.should ==
"http://www.xn--n8jaaaaai5bhf7as8fsfk3jnknefdde3f" +
"g11amb5gzdb4wi9bya3kc6lra.w3.mag.keio.ac.jp/"
end
it "should have the correct origin" do
@uri.origin.should == (
"http://www.xn--n8jaaaaai5bhf7as8fsfk3jnknefdde3f" +
"g11amb5gzdb4wi9bya3kc6lra.w3.mag.keio.ac.jp"
)
end
end
describe Addressable::URI, "with a base uri of 'http://a/b/c/d;p?q'" do
before do
@uri = Addressable::URI.parse("http://a/b/c/d;p?q")
end
# Section 5.4.1 of RFC 3986
it "when joined with 'g:h' should resolve to g:h" do
(@uri + "g:h").to_s.should == "g:h"
Addressable::URI.join(@uri, "g:h").to_s.should == "g:h"
end
# Section 5.4.1 of RFC 3986
it "when joined with 'g' should resolve to http://a/b/c/g" do
(@uri + "g").to_s.should == "http://a/b/c/g"
Addressable::URI.join(@uri.to_s, "g").to_s.should == "http://a/b/c/g"
end
# Section 5.4.1 of RFC 3986
it "when joined with './g' should resolve to http://a/b/c/g" do
(@uri + "./g").to_s.should == "http://a/b/c/g"
Addressable::URI.join(@uri.to_s, "./g").to_s.should == "http://a/b/c/g"
end
# Section 5.4.1 of RFC 3986
it "when joined with 'g/' should resolve to http://a/b/c/g/" do
(@uri + "g/").to_s.should == "http://a/b/c/g/"
Addressable::URI.join(@uri.to_s, "g/").to_s.should == "http://a/b/c/g/"
end
# Section 5.4.1 of RFC 3986
it "when joined with '/g' should resolve to http://a/g" do
(@uri + "/g").to_s.should == "http://a/g"
Addressable::URI.join(@uri.to_s, "/g").to_s.should == "http://a/g"
end
# Section 5.4.1 of RFC 3986
it "when joined with '//g' should resolve to http://g" do
(@uri + "//g").to_s.should == "http://g"
Addressable::URI.join(@uri.to_s, "//g").to_s.should == "http://g"
end
# Section 5.4.1 of RFC 3986
it "when joined with '?y' should resolve to http://a/b/c/d;p?y" do
(@uri + "?y").to_s.should == "http://a/b/c/d;p?y"
Addressable::URI.join(@uri.to_s, "?y").to_s.should == "http://a/b/c/d;p?y"
end
# Section 5.4.1 of RFC 3986
it "when joined with 'g?y' should resolve to http://a/b/c/g?y" do
(@uri + "g?y").to_s.should == "http://a/b/c/g?y"
Addressable::URI.join(@uri.to_s, "g?y").to_s.should == "http://a/b/c/g?y"
end
# Section 5.4.1 of RFC 3986
it "when joined with '#s' should resolve to http://a/b/c/d;p?q#s" do
(@uri + "#s").to_s.should == "http://a/b/c/d;p?q#s"
Addressable::URI.join(@uri.to_s, "#s").to_s.should ==
"http://a/b/c/d;p?q#s"
end
# Section 5.4.1 of RFC 3986
it "when joined with 'g#s' should resolve to http://a/b/c/g#s" do
(@uri + "g#s").to_s.should == "http://a/b/c/g#s"
Addressable::URI.join(@uri.to_s, "g#s").to_s.should == "http://a/b/c/g#s"
end
# Section 5.4.1 of RFC 3986
it "when joined with 'g?y#s' should resolve to http://a/b/c/g?y#s" do
(@uri + "g?y#s").to_s.should == "http://a/b/c/g?y#s"
Addressable::URI.join(
@uri.to_s, "g?y#s").to_s.should == "http://a/b/c/g?y#s"
end
# Section 5.4.1 of RFC 3986
it "when joined with ';x' should resolve to http://a/b/c/;x" do
(@uri + ";x").to_s.should == "http://a/b/c/;x"
Addressable::URI.join(@uri.to_s, ";x").to_s.should == "http://a/b/c/;x"
end
# Section 5.4.1 of RFC 3986
it "when joined with 'g;x' should resolve to http://a/b/c/g;x" do
(@uri + "g;x").to_s.should == "http://a/b/c/g;x"
Addressable::URI.join(@uri.to_s, "g;x").to_s.should == "http://a/b/c/g;x"
end
# Section 5.4.1 of RFC 3986
it "when joined with 'g;x?y#s' should resolve to http://a/b/c/g;x?y#s" do
(@uri + "g;x?y#s").to_s.should == "http://a/b/c/g;x?y#s"
Addressable::URI.join(
@uri.to_s, "g;x?y#s").to_s.should == "http://a/b/c/g;x?y#s"
end
# Section 5.4.1 of RFC 3986
it "when joined with '' should resolve to http://a/b/c/d;p?q" do
(@uri + "").to_s.should == "http://a/b/c/d;p?q"
Addressable::URI.join(@uri.to_s, "").to_s.should == "http://a/b/c/d;p?q"
end
# Section 5.4.1 of RFC 3986
it "when joined with '.' should resolve to http://a/b/c/" do
(@uri + ".").to_s.should == "http://a/b/c/"
Addressable::URI.join(@uri.to_s, ".").to_s.should == "http://a/b/c/"
end
# Section 5.4.1 of RFC 3986
it "when joined with './' should resolve to http://a/b/c/" do
(@uri + "./").to_s.should == "http://a/b/c/"
Addressable::URI.join(@uri.to_s, "./").to_s.should == "http://a/b/c/"
end
# Section 5.4.1 of RFC 3986
it "when joined with '..' should resolve to http://a/b/" do
(@uri + "..").to_s.should == "http://a/b/"
Addressable::URI.join(@uri.to_s, "..").to_s.should == "http://a/b/"
end
# Section 5.4.1 of RFC 3986
it "when joined with '../' should resolve to http://a/b/" do
(@uri + "../").to_s.should == "http://a/b/"
Addressable::URI.join(@uri.to_s, "../").to_s.should == "http://a/b/"
end
# Section 5.4.1 of RFC 3986
it "when joined with '../g' should resolve to http://a/b/g" do
(@uri + "../g").to_s.should == "http://a/b/g"
Addressable::URI.join(@uri.to_s, "../g").to_s.should == "http://a/b/g"
end
# Section 5.4.1 of RFC 3986
it "when joined with '../..' should resolve to http://a/" do
(@uri + "../..").to_s.should == "http://a/"
Addressable::URI.join(@uri.to_s, "../..").to_s.should == "http://a/"
end
# Section 5.4.1 of RFC 3986
it "when joined with '../../' should resolve to http://a/" do
(@uri + "../../").to_s.should == "http://a/"
Addressable::URI.join(@uri.to_s, "../../").to_s.should == "http://a/"
end
# Section 5.4.1 of RFC 3986
it "when joined with '../../g' should resolve to http://a/g" do
(@uri + "../../g").to_s.should == "http://a/g"
Addressable::URI.join(@uri.to_s, "../../g").to_s.should == "http://a/g"
end
# Section 5.4.2 of RFC 3986
it "when joined with '../../../g' should resolve to http://a/g" do
(@uri + "../../../g").to_s.should == "http://a/g"
Addressable::URI.join(@uri.to_s, "../../../g").to_s.should == "http://a/g"
end
it "when joined with '../.././../g' should resolve to http://a/g" do
(@uri + "../.././../g").to_s.should == "http://a/g"
Addressable::URI.join(@uri.to_s, "../.././../g").to_s.should ==
"http://a/g"
end
# Section 5.4.2 of RFC 3986
it "when joined with '../../../../g' should resolve to http://a/g" do
(@uri + "../../../../g").to_s.should == "http://a/g"
Addressable::URI.join(
@uri.to_s, "../../../../g").to_s.should == "http://a/g"
end
# Section 5.4.2 of RFC 3986
it "when joined with '/./g' should resolve to http://a/g" do
(@uri + "/./g").to_s.should == "http://a/g"
Addressable::URI.join(@uri.to_s, "/./g").to_s.should == "http://a/g"
end
# Section 5.4.2 of RFC 3986
it "when joined with '/../g' should resolve to http://a/g" do
(@uri + "/../g").to_s.should == "http://a/g"
Addressable::URI.join(@uri.to_s, "/../g").to_s.should == "http://a/g"
end
# Section 5.4.2 of RFC 3986
it "when joined with 'g.' should resolve to http://a/b/c/g." do
(@uri + "g.").to_s.should == "http://a/b/c/g."
Addressable::URI.join(@uri.to_s, "g.").to_s.should == "http://a/b/c/g."
end
# Section 5.4.2 of RFC 3986
it "when joined with '.g' should resolve to http://a/b/c/.g" do
(@uri + ".g").to_s.should == "http://a/b/c/.g"
Addressable::URI.join(@uri.to_s, ".g").to_s.should == "http://a/b/c/.g"
end
# Section 5.4.2 of RFC 3986
it "when joined with 'g..' should resolve to http://a/b/c/g.." do
(@uri + "g..").to_s.should == "http://a/b/c/g.."
Addressable::URI.join(@uri.to_s, "g..").to_s.should == "http://a/b/c/g.."
end
# Section 5.4.2 of RFC 3986
it "when joined with '..g' should resolve to http://a/b/c/..g" do
(@uri + "..g").to_s.should == "http://a/b/c/..g"
Addressable::URI.join(@uri.to_s, "..g").to_s.should == "http://a/b/c/..g"
end
# Section 5.4.2 of RFC 3986
it "when joined with './../g' should resolve to http://a/b/g" do
(@uri + "./../g").to_s.should == "http://a/b/g"
Addressable::URI.join(@uri.to_s, "./../g").to_s.should == "http://a/b/g"
end
# Section 5.4.2 of RFC 3986
it "when joined with './g/.' should resolve to http://a/b/c/g/" do
(@uri + "./g/.").to_s.should == "http://a/b/c/g/"
Addressable::URI.join(@uri.to_s, "./g/.").to_s.should == "http://a/b/c/g/"
end
# Section 5.4.2 of RFC 3986
it "when joined with 'g/./h' should resolve to http://a/b/c/g/h" do
(@uri + "g/./h").to_s.should == "http://a/b/c/g/h"
Addressable::URI.join(@uri.to_s, "g/./h").to_s.should == "http://a/b/c/g/h"
end
# Section 5.4.2 of RFC 3986
it "when joined with 'g/../h' should resolve to http://a/b/c/h" do
(@uri + "g/../h").to_s.should == "http://a/b/c/h"
Addressable::URI.join(@uri.to_s, "g/../h").to_s.should == "http://a/b/c/h"
end
# Section 5.4.2 of RFC 3986
it "when joined with 'g;x=1/./y' " +
"should resolve to http://a/b/c/g;x=1/y" do
(@uri + "g;x=1/./y").to_s.should == "http://a/b/c/g;x=1/y"
Addressable::URI.join(
@uri.to_s, "g;x=1/./y").to_s.should == "http://a/b/c/g;x=1/y"
end
# Section 5.4.2 of RFC 3986
it "when joined with 'g;x=1/../y' should resolve to http://a/b/c/y" do
(@uri + "g;x=1/../y").to_s.should == "http://a/b/c/y"
Addressable::URI.join(
@uri.to_s, "g;x=1/../y").to_s.should == "http://a/b/c/y"
end
# Section 5.4.2 of RFC 3986
it "when joined with 'g?y/./x' " +
"should resolve to http://a/b/c/g?y/./x" do
(@uri + "g?y/./x").to_s.should == "http://a/b/c/g?y/./x"
Addressable::URI.join(
@uri.to_s, "g?y/./x").to_s.should == "http://a/b/c/g?y/./x"
end
# Section 5.4.2 of RFC 3986
it "when joined with 'g?y/../x' " +
"should resolve to http://a/b/c/g?y/../x" do
(@uri + "g?y/../x").to_s.should == "http://a/b/c/g?y/../x"
Addressable::URI.join(
@uri.to_s, "g?y/../x").to_s.should == "http://a/b/c/g?y/../x"
end
# Section 5.4.2 of RFC 3986
it "when joined with 'g#s/./x' " +
"should resolve to http://a/b/c/g#s/./x" do
(@uri + "g#s/./x").to_s.should == "http://a/b/c/g#s/./x"
Addressable::URI.join(
@uri.to_s, "g#s/./x").to_s.should == "http://a/b/c/g#s/./x"
end
# Section 5.4.2 of RFC 3986
it "when joined with 'g#s/../x' " +
"should resolve to http://a/b/c/g#s/../x" do
(@uri + "g#s/../x").to_s.should == "http://a/b/c/g#s/../x"
Addressable::URI.join(
@uri.to_s, "g#s/../x").to_s.should == "http://a/b/c/g#s/../x"
end
# Section 5.4.2 of RFC 3986
it "when joined with 'http:g' should resolve to http:g" do
(@uri + "http:g").to_s.should == "http:g"
Addressable::URI.join(@uri.to_s, "http:g").to_s.should == "http:g"
end
# Edge case to be sure
it "when joined with '//example.com/' should " +
"resolve to http://example.com/" do
(@uri + "//example.com/").to_s.should == "http://example.com/"
Addressable::URI.join(
@uri.to_s, "//example.com/").to_s.should == "http://example.com/"
end
it "when joined with a bogus object a TypeError should be raised" do
(lambda do
Addressable::URI.join(@uri, 42)
end).should raise_error(TypeError)
end
end
describe Addressable::URI, "when converting the path " +
"'relative/path/to/something'" do
before do
@path = 'relative/path/to/something'
end
it "should convert to " +
"\'relative/path/to/something\'" do
@uri = Addressable::URI.convert_path(@path)
@uri.to_str.should == "relative/path/to/something"
end
it "should join with an absolute file path correctly" do
@base = Addressable::URI.convert_path("/absolute/path/")
@uri = Addressable::URI.convert_path(@path)
(@base + @uri).to_str.should ==
"file:///absolute/path/relative/path/to/something"
end
end
describe Addressable::URI, "when converting a bogus path" do
it "should raise a TypeError" do
(lambda do
Addressable::URI.convert_path(42)
end).should raise_error(TypeError)
end
end
describe Addressable::URI, "when given a UNIX root directory" do
before do
@path = "/"
end
it "should convert to \'file:///\'" do
@uri = Addressable::URI.convert_path(@path)
@uri.to_str.should == "file:///"
end
it "should have an origin of 'file://'" do
@uri = Addressable::URI.convert_path(@path)
@uri.origin.should == 'file://'
end
end
describe Addressable::URI, "when given a Windows root directory" do
before do
@path = "C:\\"
end
it "should convert to \'file:///c:/\'" do
@uri = Addressable::URI.convert_path(@path)
@uri.to_str.should == "file:///c:/"
end
it "should have an origin of 'file://'" do
@uri = Addressable::URI.convert_path(@path)
@uri.origin.should == 'file://'
end
end
describe Addressable::URI, "when given the path '/one/two/'" do
before do
@path = '/one/two/'
end
it "should convert to " +
"\'file:///one/two/\'" do
@uri = Addressable::URI.convert_path(@path)
@uri.to_str.should == "file:///one/two/"
end
it "should have an origin of 'file://'" do
@uri = Addressable::URI.convert_path(@path)
@uri.origin.should == 'file://'
end
end
describe Addressable::URI, "when given the path " +
"'c:\\windows\\My Documents 100%20\\foo.txt'" do
before do
@path = "c:\\windows\\My Documents 100%20\\foo.txt"
end
it "should convert to " +
"\'file:///c:/windows/My%20Documents%20100%20/foo.txt\'" do
@uri = Addressable::URI.convert_path(@path)
@uri.to_str.should == "file:///c:/windows/My%20Documents%20100%20/foo.txt"
end
it "should have an origin of 'file://'" do
@uri = Addressable::URI.convert_path(@path)
@uri.origin.should == 'file://'
end
end
describe Addressable::URI, "when given the path " +
"'file://c:\\windows\\My Documents 100%20\\foo.txt'" do
before do
@path = "file://c:\\windows\\My Documents 100%20\\foo.txt"
end
it "should convert to " +
"\'file:///c:/windows/My%20Documents%20100%20/foo.txt\'" do
@uri = Addressable::URI.convert_path(@path)
@uri.to_str.should == "file:///c:/windows/My%20Documents%20100%20/foo.txt"
end
it "should have an origin of 'file://'" do
@uri = Addressable::URI.convert_path(@path)
@uri.origin.should == 'file://'
end
end
describe Addressable::URI, "when given the path " +
"'file:c:\\windows\\My Documents 100%20\\foo.txt'" do
before do
@path = "file:c:\\windows\\My Documents 100%20\\foo.txt"
end
it "should convert to " +
"\'file:///c:/windows/My%20Documents%20100%20/foo.txt\'" do
@uri = Addressable::URI.convert_path(@path)
@uri.to_str.should == "file:///c:/windows/My%20Documents%20100%20/foo.txt"
end
it "should have an origin of 'file://'" do
@uri = Addressable::URI.convert_path(@path)
@uri.origin.should == 'file://'
end
end
describe Addressable::URI, "when given the path " +
"'file:/c:\\windows\\My Documents 100%20\\foo.txt'" do
before do
@path = "file:/c:\\windows\\My Documents 100%20\\foo.txt"
end
it "should convert to " +
"\'file:///c:/windows/My%20Documents%20100%20/foo.txt\'" do
@uri = Addressable::URI.convert_path(@path)
@uri.to_str.should == "file:///c:/windows/My%20Documents%20100%20/foo.txt"
end
it "should have an origin of 'file://'" do
@uri = Addressable::URI.convert_path(@path)
@uri.origin.should == 'file://'
end
end
describe Addressable::URI, "when given the path " +
"'file:///c|/windows/My%20Documents%20100%20/foo.txt'" do
before do
@path = "file:///c|/windows/My%20Documents%20100%20/foo.txt"
end
it "should convert to " +
"\'file:///c:/windows/My%20Documents%20100%20/foo.txt\'" do
@uri = Addressable::URI.convert_path(@path)
@uri.to_str.should == "file:///c:/windows/My%20Documents%20100%20/foo.txt"
end
it "should have an origin of 'file://'" do
@uri = Addressable::URI.convert_path(@path)
@uri.origin.should == 'file://'
end
end
describe Addressable::URI, "when given an http protocol URI" do
before do
@path = "http://example.com/"
end
it "should not do any conversion at all" do
@uri = Addressable::URI.convert_path(@path)
@uri.to_str.should == "http://example.com/"
end
end
class SuperString
def initialize(string)
@string = string.to_s
end
def to_str
return @string
end
end
describe Addressable::URI, "when parsing a non-String object" do
it "should correctly parse anything with a 'to_str' method" do
Addressable::URI.parse(SuperString.new(42))
end
it "should raise a TypeError for objects than cannot be converted" do
(lambda do
Addressable::URI.parse(42)
end).should raise_error(TypeError, "Can't convert Fixnum into String.")
end
it "should correctly parse heuristically anything with a 'to_str' method" do
Addressable::URI.heuristic_parse(SuperString.new(42))
end
it "should raise a TypeError for objects than cannot be converted" do
(lambda do
Addressable::URI.heuristic_parse(42)
end).should raise_error(TypeError, "Can't convert Fixnum into String.")
end
end
describe Addressable::URI, "when form encoding a hash" do
it "should result in correct percent encoded sequence" do
Addressable::URI.form_encode(
[["&one", "/1"], ["=two", "?2"], [":three", "#3"]]
).should == "%26one=%2F1&%3Dtwo=%3F2&%3Athree=%233"
end
it "should result in correct percent encoded sequence" do
Addressable::URI.form_encode(
{"q" => "one two three"}
).should == "q=one+two+three"
end
it "should result in correct percent encoded sequence" do
Addressable::URI.form_encode(
{"key" => nil}
).should == "key="
end
it "should result in correct percent encoded sequence" do
Addressable::URI.form_encode(
{"q" => ["one", "two", "three"]}
).should == "q=one&q=two&q=three"
end
it "should result in correctly encoded newlines" do
Addressable::URI.form_encode(
{"text" => "one\ntwo\rthree\r\nfour\n\r"}
).should == "text=one%0D%0Atwo%0D%0Athree%0D%0Afour%0D%0A%0D%0A"
end
it "should result in a sorted percent encoded sequence" do
Addressable::URI.form_encode(
[["a", "1"], ["dup", "3"], ["dup", "2"]], true
).should == "a=1&dup=2&dup=3"
end
end
describe Addressable::URI, "when form encoding a non-Array object" do
it "should raise a TypeError for objects than cannot be converted" do
(lambda do
Addressable::URI.form_encode(42)
end).should raise_error(TypeError, "Can't convert Fixnum into Array.")
end
end
describe Addressable::URI, "when form unencoding a string" do
it "should result in correct values" do
Addressable::URI.form_unencode(
"%26one=%2F1&%3Dtwo=%3F2&%3Athree=%233"
).should == [["&one", "/1"], ["=two", "?2"], [":three", "#3"]]
end
it "should result in correct values" do
Addressable::URI.form_unencode(
"q=one+two+three"
).should == [["q", "one two three"]]
end
it "should result in correct values" do
Addressable::URI.form_unencode(
"text=one%0D%0Atwo%0D%0Athree%0D%0Afour%0D%0A%0D%0A"
).should == [["text", "one\ntwo\nthree\nfour\n\n"]]
end
it "should result in correct values" do
Addressable::URI.form_unencode(
"a=1&dup=2&dup=3"
).should == [["a", "1"], ["dup", "2"], ["dup", "3"]]
end
it "should result in correct values" do
Addressable::URI.form_unencode(
"key"
).should == [["key", nil]]
end
it "should result in correct values" do
Addressable::URI.form_unencode("GivenName=Ren%C3%A9").should ==
[["GivenName", "René"]]
end
end
describe Addressable::URI, "when form unencoding a non-String object" do
it "should correctly parse anything with a 'to_str' method" do
Addressable::URI.form_unencode(SuperString.new(42))
end
it "should raise a TypeError for objects than cannot be converted" do
(lambda do
Addressable::URI.form_unencode(42)
end).should raise_error(TypeError, "Can't convert Fixnum into String.")
end
end
describe Addressable::URI, "when normalizing a non-String object" do
it "should correctly parse anything with a 'to_str' method" do
Addressable::URI.normalize_component(SuperString.new(42))
end
it "should raise a TypeError for objects than cannot be converted" do
(lambda do
Addressable::URI.normalize_component(42)
end).should raise_error(TypeError, "Can't convert Fixnum into String.")
end
it "should raise a TypeError for objects than cannot be converted" do
(lambda do
Addressable::URI.normalize_component("component", 42)
end).should raise_error(TypeError)
end
end
describe Addressable::URI, "when normalizing a path with an encoded slash" do
it "should result in correct percent encoded sequence" do
Addressable::URI.parse("/path%2Fsegment/").normalize.path.should ==
"/path%2Fsegment/"
end
end
describe Addressable::URI, "when normalizing a partially encoded string" do
it "should result in correct percent encoded sequence" do
Addressable::URI.normalize_component(
"partially % encoded%21"
).should == "partially%20%25%20encoded!"
end
it "should result in correct percent encoded sequence" do
Addressable::URI.normalize_component(
"partially %25 encoded!"
).should == "partially%20%25%20encoded!"
end
end
describe Addressable::URI, "when normalizing a unicode sequence" do
it "should result in correct percent encoded sequence" do
Addressable::URI.normalize_component(
"/C%CC%A7"
).should == "/%C3%87"
end
it "should result in correct percent encoded sequence" do
Addressable::URI.normalize_component(
"/%C3%87"
).should == "/%C3%87"
end
end
describe Addressable::URI, "when normalizing a multibyte string" do
it "should result in correct percent encoded sequence" do
Addressable::URI.normalize_component("günther").should ==
"g%C3%BCnther"
end
it "should result in correct percent encoded sequence" do
Addressable::URI.normalize_component("g%C3%BCnther").should ==
"g%C3%BCnther"
end
end
describe Addressable::URI, "when normalizing a string but leaving some characters encoded" do
it "should result in correct percent encoded sequence" do
Addressable::URI.normalize_component("%58X%59Y%5AZ", "0-9a-zXY", "Y").should ==
"XX%59Y%5A%5A"
end
end
describe Addressable::URI, "when encoding a string with existing encodings to upcase" do
it "should result in correct percent encoded sequence" do
Addressable::URI.encode_component("JK%4c", "0-9A-IKM-Za-z%", "L").should == "%4AK%4C"
end
end
describe Addressable::URI, "when encoding a multibyte string" do
it "should result in correct percent encoded sequence" do
Addressable::URI.encode_component("günther").should == "g%C3%BCnther"
end
it "should result in correct percent encoded sequence" do
Addressable::URI.encode_component(
"günther", /[^a-zA-Z0-9\:\/\?\#\[\]\@\!\$\&\'\(\)\*\+\,\;\=\-\.\_\~]/
).should == "g%C3%BCnther"
end
end
describe Addressable::URI, "when form encoding a multibyte string" do
it "should result in correct percent encoded sequence" do
Addressable::URI.form_encode({"GivenName" => "René"}).should ==
"GivenName=Ren%C3%A9"
end
end
describe Addressable::URI, "when encoding a string with ASCII chars 0-15" do
it "should result in correct percent encoded sequence" do
Addressable::URI.encode_component("one\ntwo").should == "one%0Atwo"
end
it "should result in correct percent encoded sequence" do
Addressable::URI.encode_component(
"one\ntwo", /[^a-zA-Z0-9\:\/\?\#\[\]\@\!\$\&\'\(\)\*\+\,\;\=\-\.\_\~]/
).should == "one%0Atwo"
end
end
describe Addressable::URI, "when unencoding a multibyte string" do
it "should result in correct percent encoded sequence" do
Addressable::URI.unencode_component("g%C3%BCnther").should == "günther"
end
it "should result in correct percent encoded sequence as a URI" do
Addressable::URI.unencode(
"/path?g%C3%BCnther", ::Addressable::URI
).should == Addressable::URI.new(
:path => "/path", :query => "günther"
)
end
end
describe Addressable::URI, "when partially unencoding a string" do
it "should unencode all characters by default" do
Addressable::URI.unencode('%%25~%7e+%2b', String).should == '%%~~++'
end
it "should unencode characters not in leave_encoded" do
Addressable::URI.unencode('%%25~%7e+%2b', String, '~').should == '%%~%7e++'
end
it "should leave characters in leave_encoded alone" do
Addressable::URI.unencode('%%25~%7e+%2b', String, '%~+').should == '%%25~%7e+%2b'
end
end
describe Addressable::URI, "when unencoding a bogus object" do
it "should raise a TypeError" do
(lambda do
Addressable::URI.unencode_component(42)
end).should raise_error(TypeError)
end
it "should raise a TypeError" do
(lambda do
Addressable::URI.unencode("/path?g%C3%BCnther", Integer)
end).should raise_error(TypeError)
end
end
describe Addressable::URI, "when encoding a bogus object" do
it "should raise a TypeError" do
(lambda do
Addressable::URI.encode(Object.new)
end).should raise_error(TypeError)
end
it "should raise a TypeError" do
(lambda do
Addressable::URI.normalized_encode(Object.new)
end).should raise_error(TypeError)
end
it "should raise a TypeError" do
(lambda do
Addressable::URI.encode_component("günther", Object.new)
end).should raise_error(TypeError)
end
it "should raise a TypeError" do
(lambda do
Addressable::URI.encode_component(Object.new)
end).should raise_error(TypeError)
end
end
describe Addressable::URI, "when given the input " +
"'http://example.com/'" do
before do
@input = "http://example.com/"
end
it "should heuristically parse to 'http://example.com/'" do
@uri = Addressable::URI.heuristic_parse(@input)
@uri.to_s.should == "http://example.com/"
end
it "should not raise error when frozen" do
(lambda do
Addressable::URI.heuristic_parse(@input).freeze.to_s
end).should_not raise_error
end
end
describe Addressable::URI, "when given the input " +
"'https://example.com/'" do
before do
@input = "https://example.com/"
end
it "should heuristically parse to 'https://example.com/'" do
@uri = Addressable::URI.heuristic_parse(@input)
@uri.to_s.should == "https://example.com/"
end
end
describe Addressable::URI, "when given the input " +
"'http:example.com/'" do
before do
@input = "http:example.com/"
end
it "should heuristically parse to 'http://example.com/'" do
@uri = Addressable::URI.heuristic_parse(@input)
@uri.to_s.should == "http://example.com/"
end
it "should heuristically parse to 'http://example.com/' " +
"even with a scheme hint of 'ftp'" do
@uri = Addressable::URI.heuristic_parse(@input, {:scheme => 'ftp'})
@uri.to_s.should == "http://example.com/"
end
end
describe Addressable::URI, "when given the input " +
"'https:example.com/'" do
before do
@input = "https:example.com/"
end
it "should heuristically parse to 'https://example.com/'" do
@uri = Addressable::URI.heuristic_parse(@input)
@uri.to_s.should == "https://example.com/"
end
it "should heuristically parse to 'https://example.com/' " +
"even with a scheme hint of 'ftp'" do
@uri = Addressable::URI.heuristic_parse(@input, {:scheme => 'ftp'})
@uri.to_s.should == "https://example.com/"
end
end
describe Addressable::URI, "when given the input " +
"'http://example.com/example.com/'" do
before do
@input = "http://example.com/example.com/"
end
it "should heuristically parse to 'http://example.com/example.com/'" do
@uri = Addressable::URI.heuristic_parse(@input)
@uri.to_s.should == "http://example.com/example.com/"
end
end
describe Addressable::URI, "when given the input " +
"'/path/to/resource'" do
before do
@input = "/path/to/resource"
end
it "should heuristically parse to '/path/to/resource'" do
@uri = Addressable::URI.heuristic_parse(@input)
@uri.to_s.should == "/path/to/resource"
end
end
describe Addressable::URI, "when given the input " +
"'relative/path/to/resource'" do
before do
@input = "relative/path/to/resource"
end
it "should heuristically parse to 'relative/path/to/resource'" do
@uri = Addressable::URI.heuristic_parse(@input)
@uri.to_s.should == "relative/path/to/resource"
end
end
describe Addressable::URI, "when given the input " +
"'example.com'" do
before do
@input = "example.com"
end
it "should heuristically parse to 'http://example.com'" do
@uri = Addressable::URI.heuristic_parse(@input)
@uri.to_s.should == "http://example.com"
end
end
describe Addressable::URI, "when given the input " +
"'example.com' and a scheme hint of 'ftp'" do
before do
@input = "example.com"
@hints = {:scheme => 'ftp'}
end
it "should heuristically parse to 'http://example.com'" do
@uri = Addressable::URI.heuristic_parse(@input, @hints)
@uri.to_s.should == "ftp://example.com"
end
end
describe Addressable::URI, "when given the input " +
"'example.com:21' and a scheme hint of 'ftp'" do
before do
@input = "example.com:21"
@hints = {:scheme => 'ftp'}
end
it "should heuristically parse to 'http://example.com:21'" do
@uri = Addressable::URI.heuristic_parse(@input, @hints)
@uri.to_s.should == "ftp://example.com:21"
end
end
describe Addressable::URI, "when given the input " +
"'example.com/path/to/resource'" do
before do
@input = "example.com/path/to/resource"
end
it "should heuristically parse to 'http://example.com/path/to/resource'" do
@uri = Addressable::URI.heuristic_parse(@input)
@uri.to_s.should == "http://example.com/path/to/resource"
end
end
describe Addressable::URI, "when given the input " +
"'http:///example.com'" do
before do
@input = "http:///example.com"
end
it "should heuristically parse to 'http://example.com'" do
@uri = Addressable::URI.heuristic_parse(@input)
@uri.to_s.should == "http://example.com"
end
end
describe Addressable::URI, "when given the input " +
"'feed:///example.com'" do
before do
@input = "feed:///example.com"
end
it "should heuristically parse to 'feed://example.com'" do
@uri = Addressable::URI.heuristic_parse(@input)
@uri.to_s.should == "feed://example.com"
end
end
describe Addressable::URI, "when given the input " +
"'file://path/to/resource/'" do
before do
@input = "file://path/to/resource/"
end
it "should heuristically parse to 'file:///path/to/resource/'" do
@uri = Addressable::URI.heuristic_parse(@input)
@uri.to_s.should == "file:///path/to/resource/"
end
end
describe Addressable::URI, "when given the input " +
"'feed://http://example.com'" do
before do
@input = "feed://http://example.com"
end
it "should heuristically parse to 'feed:http://example.com'" do
@uri = Addressable::URI.heuristic_parse(@input)
@uri.to_s.should == "feed:http://example.com"
end
end
describe Addressable::URI, "when assigning query values" do
before do
@uri = Addressable::URI.new
end
it "should correctly assign {:a => 'a', :b => ['c', 'd', 'e']}" do
@uri.query_values = {:a => "a", :b => ["c", "d", "e"]}
@uri.query.should == "a=a&b=c&b=d&b=e"
end
it "should raise an error attempting to assign {'a' => {'b' => ['c']}}" do
(lambda do
@uri.query_values = { 'a' => {'b' => ['c'] } }
end).should raise_error(TypeError)
end
it "should raise an error attempting to assign " +
"{:b => '2', :a => {:c => '1'}}" do
(lambda do
@uri.query_values = {:b => '2', :a => {:c => '1'}}
end).should raise_error(TypeError)
end
it "should raise an error attempting to assign " +
"{:a => 'a', :b => [{:c => 'c', :d => 'd'}, " +
"{:e => 'e', :f => 'f'}]}" do
(lambda do
@uri.query_values = {
:a => "a", :b => [{:c => "c", :d => "d"}, {:e => "e", :f => "f"}]
}
end).should raise_error(TypeError)
end
it "should raise an error attempting to assign " +
"{:a => 'a', :b => [{:c => true, :d => 'd'}, " +
"{:e => 'e', :f => 'f'}]}" do
(lambda do
@uri.query_values = {
:a => 'a', :b => [{:c => true, :d => 'd'}, {:e => 'e', :f => 'f'}]
}
end).should raise_error(TypeError)
end
it "should raise an error attempting to assign " +
"{:a => 'a', :b => {:c => true, :d => 'd'}}" do
(lambda do
@uri.query_values = {
:a => 'a', :b => {:c => true, :d => 'd'}
}
end).should raise_error(TypeError)
end
it "should raise an error attempting to assign " +
"{:a => 'a', :b => {:c => true, :d => 'd'}}" do
(lambda do
@uri.query_values = {
:a => 'a', :b => {:c => true, :d => 'd'}
}
end).should raise_error(TypeError)
end
it "should correctly assign {:a => 1, :b => 1.5}" do
@uri.query_values = { :a => 1, :b => 1.5 }
@uri.query.should == "a=1&b=1.5"
end
it "should raise an error attempting to assign " +
"{:z => 1, :f => [2, {999.1 => [3,'4']}, ['h', 'i']], " +
":a => {:b => ['c', 'd'], :e => true, :y => 0.5}}" do
(lambda do
@uri.query_values = {
:z => 1,
:f => [ 2, {999.1 => [3,'4']}, ['h', 'i'] ],
:a => { :b => ['c', 'd'], :e => true, :y => 0.5 }
}
end).should raise_error(TypeError)
end
it "should correctly assign {}" do
@uri.query_values = {}
@uri.query.should == ''
end
it "should correctly assign nil" do
@uri.query_values = nil
@uri.query.should == nil
end
it "should correctly sort {'ab' => 'c', :ab => 'a', :a => 'x'}" do
@uri.query_values = {'ab' => 'c', :ab => 'a', :a => 'x'}
@uri.query.should == "a=x&ab=a&ab=c"
end
it "should correctly assign " +
"[['b', 'c'], ['b', 'a'], ['a', 'a']]" do
# Order can be guaranteed in this format, so preserve it.
@uri.query_values = [['b', 'c'], ['b', 'a'], ['a', 'a']]
@uri.query.should == "b=c&b=a&a=a"
end
it "should preserve query string order" do
query_string = (('a'..'z').to_a.reverse.map { |e| "#{e}=#{e}" }).join("&")
@uri.query = query_string
original_uri = @uri.to_s
@uri.query_values = @uri.query_values(Array)
@uri.to_s.should == original_uri
end
describe 'when a hash with mixed types is assigned to query_values' do
it 'should not raise an error' do
pending 'Issue #94' do
expect { subject.query_values = { "page" => "1", :page => 2 } }.to_not raise_error ArgumentError
end
end
end
end
describe Addressable::URI, "when assigning path values" do
before do
@uri = Addressable::URI.new
end
it "should correctly assign paths containing colons" do
@uri.path = "acct:bob@sporkmonger.com"
@uri.path.should == "acct:bob@sporkmonger.com"
@uri.normalize.to_str.should == "acct%2Fbob@sporkmonger.com"
(lambda { @uri.to_s }).should raise_error(
Addressable::URI::InvalidURIError
)
end
it "should correctly assign paths containing colons" do
@uri.path = "/acct:bob@sporkmonger.com"
@uri.authority = "example.com"
@uri.normalize.to_str.should == "//example.com/acct:bob@sporkmonger.com"
end
it "should correctly assign paths containing colons" do
@uri.path = "acct:bob@sporkmonger.com"
@uri.scheme = "something"
@uri.normalize.to_str.should == "something:acct:bob@sporkmonger.com"
end
it "should not allow relative paths to be assigned on absolute URIs" do
(lambda do
@uri.scheme = "http"
@uri.host = "example.com"
@uri.path = "acct:bob@sporkmonger.com"
end).should raise_error(Addressable::URI::InvalidURIError)
end
it "should not allow relative paths to be assigned on absolute URIs" do
(lambda do
@uri.path = "acct:bob@sporkmonger.com"
@uri.scheme = "http"
@uri.host = "example.com"
end).should raise_error(Addressable::URI::InvalidURIError)
end
it "should not allow relative paths to be assigned on absolute URIs" do
(lambda do
@uri.path = "uuid:0b3ecf60-3f93-11df-a9c3-001f5bfffe12"
@uri.scheme = "urn"
end).should_not raise_error(Addressable::URI::InvalidURIError)
end
end
addressable-2.3.4/spec/addressable/template_spec.rb 0000644 0000041 0000041 00000101467 12146365675 022426 0 ustar www-data www-data require "addressable/template"
shared_examples_for 'expands' do |tests|
tests.each do |template, expansion|
exp = expansion.is_a?(Array) ? expansion.first : expansion
it "#{template} to #{exp}" do
tmpl = Addressable::Template.new(template).expand(subject)
if expansion.is_a?(Array)
expansion.any?{|i| i == tmpl.to_str}.should be_true
else
tmpl.to_str.should == expansion
end
end
end
end
describe "Type conversion" do
subject{
{:var => true, :hello => 1234, :nothing => nil, :sym => :symbolic}
}
it_behaves_like 'expands', {
'{var}' => 'true',
'{hello}' => '1234',
'{nothing}' => '',
'{sym}' => 'symbolic'
}
end
describe "Level 1:" do
subject{
{:var => "value", :hello => "Hello World!"}
}
it_behaves_like 'expands', {
'{var}' => 'value',
'{hello}' => 'Hello%20World%21'
}
end
describe "Level 2" do
subject{
{
:var => "value",
:hello => "Hello World!",
:path => "/foo/bar"
}
}
context "Operator +:" do
it_behaves_like 'expands', {
'{+var}' => 'value',
'{+hello}' => 'Hello%20World!',
'{+path}/here' => '/foo/bar/here',
'here?ref={+path}' => 'here?ref=/foo/bar'
}
end
context "Operator #:" do
it_behaves_like 'expands', {
'X{#var}' => 'X#value',
'X{#hello}' => 'X#Hello%20World!'
}
end
end
describe "Level 3" do
subject{
{
:var => "value",
:hello => "Hello World!",
:empty => "",
:path => "/foo/bar",
:x => "1024",
:y => "768"
}
}
context "Operator nil (multiple vars):" do
it_behaves_like 'expands', {
'map?{x,y}' => 'map?1024,768',
'{x,hello,y}' => '1024,Hello%20World%21,768'
}
end
context "Operator + (multiple vars):" do
it_behaves_like 'expands', {
'{+x,hello,y}' => '1024,Hello%20World!,768',
'{+path,x}/here' => '/foo/bar,1024/here'
}
end
context "Operator # (multiple vars):" do
it_behaves_like 'expands', {
'{#x,hello,y}' => '#1024,Hello%20World!,768',
'{#path,x}/here' => '#/foo/bar,1024/here'
}
end
context "Operator ." do
it_behaves_like 'expands', {
'X{.var}' => 'X.value',
'X{.x,y}' => 'X.1024.768'
}
end
context "Operator /" do
it_behaves_like 'expands', {
'{/var}' => '/value',
'{/var,x}/here' => '/value/1024/here'
}
end
context "Operator ;" do
it_behaves_like 'expands', {
'{;x,y}' => ';x=1024;y=768',
'{;x,y,empty}' => ';x=1024;y=768;empty'
}
end
context "Operator ?" do
it_behaves_like 'expands', {
'{?x,y}' => '?x=1024&y=768',
'{?x,y,empty}' => '?x=1024&y=768&empty='
}
end
context "Operator &" do
it_behaves_like 'expands', {
'?fixed=yes{&x}' => '?fixed=yes&x=1024',
'{&x,y,empty}' => '&x=1024&y=768&empty='
}
end
end
describe "Level 4" do
subject{
{
:var => "value",
:hello => "Hello World!",
:path => "/foo/bar",
:semi => ";",
:list => %w(red green blue),
:keys => {"semi" => ';', "dot" => '.', "comma" => ','}
}
}
context "Expansion with value modifiers" do
it_behaves_like 'expands', {
'{var:3}' => 'val',
'{var:30}' => 'value',
'{list}' => 'red,green,blue',
'{list*}' => 'red,green,blue',
'{keys}' => [
'semi,%3B,dot,.,comma,%2C',
'dot,.,semi,%3B,comma,%2C',
'comma,%2C,semi,%3B,dot,.',
'semi,%3B,comma,%2C,dot,.',
'dot,.,comma,%2C,semi,%3B',
'comma,%2C,dot,.,semi,%3B'
],
'{keys*}' => [
'semi=%3B,dot=.,comma=%2C',
'dot=.,semi=%3B,comma=%2C',
'comma=%2C,semi=%3B,dot=.',
'semi=%3B,comma=%2C,dot=.',
'dot=.,comma=%2C,semi=%3B',
'comma=%2C,dot=.,semi=%3B'
]
}
end
context "Operator + with value modifiers" do
it_behaves_like 'expands', {
'{+path:6}/here' => '/foo/b/here',
'{+list}' => 'red,green,blue',
'{+list*}' => 'red,green,blue',
'{+keys}' => [
'semi,;,dot,.,comma,,',
'dot,.,semi,;,comma,,',
'comma,,,semi,;,dot,.',
'semi,;,comma,,,dot,.',
'dot,.,comma,,,semi,;',
'comma,,,dot,.,semi,;'
],
'{+keys*}' => [
'semi=;,dot=.,comma=,',
'dot=.,semi=;,comma=,',
'comma=,,semi=;,dot=.',
'semi=;,comma=,,dot=.',
'dot=.,comma=,,semi=;',
'comma=,,dot=.,semi=;'
]
}
end
context "Operator # with value modifiers" do
it_behaves_like 'expands', {
'{#path:6}/here' => '#/foo/b/here',
'{#list}' => '#red,green,blue',
'{#list*}' => '#red,green,blue',
'{#keys}' => [
'#semi,;,dot,.,comma,,',
'#dot,.,semi,;,comma,,',
'#comma,,,semi,;,dot,.',
'#semi,;,comma,,,dot,.',
'#dot,.,comma,,,semi,;',
'#comma,,,dot,.,semi,;'
],
'{#keys*}' => [
'#semi=;,dot=.,comma=,',
'#dot=.,semi=;,comma=,',
'#comma=,,semi=;,dot=.',
'#semi=;,comma=,,dot=.',
'#dot=.,comma=,,semi=;',
'#comma=,,dot=.,semi=;'
]
}
end
context "Operator . with value modifiers" do
it_behaves_like 'expands', {
'X{.var:3}' => 'X.val',
'X{.list}' => 'X.red,green,blue',
'X{.list*}' => 'X.red.green.blue',
'X{.keys}' => [
'X.semi,%3B,dot,.,comma,%2C',
'X.dot,.,semi,%3B,comma,%2C',
'X.comma,%2C,semi,%3B,dot,.',
'X.semi,%3B,comma,%2C,dot,.',
'X.dot,.,comma,%2C,semi,%3B',
'X.comma,%2C,dot,.,semi,%3B'
],
'X{.keys*}' => [
'X.semi=%3B.dot=..comma=%2C',
'X.dot=..semi=%3B.comma=%2C',
'X.comma=%2C.semi=%3B.dot=.',
'X.semi=%3B.comma=%2C.dot=.',
'X.dot=..comma=%2C.semi=%3B',
'X.comma=%2C.dot=..semi=%3B'
]
}
end
context "Operator / with value modifiers" do
it_behaves_like 'expands', {
'{/var:1,var}' => '/v/value',
'{/list}' => '/red,green,blue',
'{/list*}' => '/red/green/blue',
'{/list*,path:4}' => '/red/green/blue/%2Ffoo',
'{/keys}' => [
'/semi,%3B,dot,.,comma,%2C',
'/dot,.,semi,%3B,comma,%2C',
'/comma,%2C,semi,%3B,dot,.',
'/semi,%3B,comma,%2C,dot,.',
'/dot,.,comma,%2C,semi,%3B',
'/comma,%2C,dot,.,semi,%3B'
],
'{/keys*}' => [
'/semi=%3B/dot=./comma=%2C',
'/dot=./semi=%3B/comma=%2C',
'/comma=%2C/semi=%3B/dot=.',
'/semi=%3B/comma=%2C/dot=.',
'/dot=./comma=%2C/semi=%3B',
'/comma=%2C/dot=./semi=%3B'
]
}
end
context "Operator ; with value modifiers" do
it_behaves_like 'expands', {
'{;hello:5}' => ';hello=Hello',
'{;list}' => ';list=red,green,blue',
'{;list*}' => ';list=red;list=green;list=blue',
'{;keys}' => [
';keys=semi,%3B,dot,.,comma,%2C',
';keys=dot,.,semi,%3B,comma,%2C',
';keys=comma,%2C,semi,%3B,dot,.',
';keys=semi,%3B,comma,%2C,dot,.',
';keys=dot,.,comma,%2C,semi,%3B',
';keys=comma,%2C,dot,.,semi,%3B'
],
'{;keys*}' => [
';semi=%3B;dot=.;comma=%2C',
';dot=.;semi=%3B;comma=%2C',
';comma=%2C;semi=%3B;dot=.',
';semi=%3B;comma=%2C;dot=.',
';dot=.;comma=%2C;semi=%3B',
';comma=%2C;dot=.;semi=%3B'
]
}
end
context "Operator ? with value modifiers" do
it_behaves_like 'expands', {
'{?var:3}' => '?var=val',
'{?list}' => '?list=red,green,blue',
'{?list*}' => '?list=red&list=green&list=blue',
'{?keys}' => [
'?keys=semi,%3B,dot,.,comma,%2C',
'?keys=dot,.,semi,%3B,comma,%2C',
'?keys=comma,%2C,semi,%3B,dot,.',
'?keys=semi,%3B,comma,%2C,dot,.',
'?keys=dot,.,comma,%2C,semi,%3B',
'?keys=comma,%2C,dot,.,semi,%3B'
],
'{?keys*}' => [
'?semi=%3B&dot=.&comma=%2C',
'?dot=.&semi=%3B&comma=%2C',
'?comma=%2C&semi=%3B&dot=.',
'?semi=%3B&comma=%2C&dot=.',
'?dot=.&comma=%2C&semi=%3B',
'?comma=%2C&dot=.&semi=%3B'
]
}
end
context "Operator & with value modifiers" do
it_behaves_like 'expands', {
'{&var:3}' => '&var=val',
'{&list}' => '&list=red,green,blue',
'{&list*}' => '&list=red&list=green&list=blue',
'{&keys}' => [
'&keys=semi,%3B,dot,.,comma,%2C',
'&keys=dot,.,semi,%3B,comma,%2C',
'&keys=comma,%2C,semi,%3B,dot,.',
'&keys=semi,%3B,comma,%2C,dot,.',
'&keys=dot,.,comma,%2C,semi,%3B',
'&keys=comma,%2C,dot,.,semi,%3B'
],
'{&keys*}' => [
'&semi=%3B&dot=.&comma=%2C',
'&dot=.&semi=%3B&comma=%2C',
'&comma=%2C&semi=%3B&dot=.',
'&semi=%3B&comma=%2C&dot=.',
'&dot=.&comma=%2C&semi=%3B',
'&comma=%2C&dot=.&semi=%3B'
]
}
end
end
describe "Modifiers" do
subject{
{
:var => "value",
:semi => ";",
:year => %w(1965 2000 2012),
:dom => %w(example com)
}
}
context "length" do
it_behaves_like 'expands', {
'{var:3}' => 'val',
'{var:30}' => 'value',
'{var}' => 'value',
'{semi}' => '%3B',
'{semi:2}' => '%3B'
}
end
context "explode" do
it_behaves_like 'expands', {
'find{?year*}' => 'find?year=1965&year=2000&year=2012',
'www{.dom*}' => 'www.example.com',
}
end
end
describe "Expansion" do
subject{
{
:count => ["one", "two", "three"],
:dom => ["example", "com"],
:dub => "me/too",
:hello => "Hello World!",
:half => "50%",
:var => "value",
:who => "fred",
:base => "http://example.com/home/",
:path => "/foo/bar",
:list => ["red", "green", "blue"],
:keys => {"semi" => ";","dot" => ".","comma" => ","},
:v => "6",
:x => "1024",
:y => "768",
:empty => "",
:empty_keys => {},
:undef => nil
}
}
context "concatenation" do
it_behaves_like 'expands', {
'{count}' => 'one,two,three',
'{count*}' => 'one,two,three',
'{/count}' => '/one,two,three',
'{/count*}' => '/one/two/three',
'{;count}' => ';count=one,two,three',
'{;count*}' => ';count=one;count=two;count=three',
'{?count}' => '?count=one,two,three',
'{?count*}' => '?count=one&count=two&count=three',
'{&count*}' => '&count=one&count=two&count=three'
}
end
context "simple expansion" do
it_behaves_like 'expands', {
'{var}' => 'value',
'{hello}' => 'Hello%20World%21',
'{half}' => '50%25',
'O{empty}X' => 'OX',
'O{undef}X' => 'OX',
'{x,y}' => '1024,768',
'{x,hello,y}' => '1024,Hello%20World%21,768',
'?{x,empty}' => '?1024,',
'?{x,undef}' => '?1024',
'?{undef,y}' => '?768',
'{var:3}' => 'val',
'{var:30}' => 'value',
'{list}' => 'red,green,blue',
'{list*}' => 'red,green,blue',
'{keys}' => [
'semi,%3B,dot,.,comma,%2C',
'dot,.,semi,%3B,comma,%2C',
'comma,%2C,semi,%3B,dot,.',
'semi,%3B,comma,%2C,dot,.',
'dot,.,comma,%2C,semi,%3B',
'comma,%2C,dot,.,semi,%3B'
],
'{keys*}' => [
'semi=%3B,dot=.,comma=%2C',
'dot=.,semi=%3B,comma=%2C',
'comma=%2C,semi=%3B,dot=.',
'semi=%3B,comma=%2C,dot=.',
'dot=.,comma=%2C,semi=%3B',
'comma=%2C,dot=.,semi=%3B'
]
}
end
context "reserved expansion (+)" do
it_behaves_like 'expands', {
'{+var}' => 'value',
'{+hello}' => 'Hello%20World!',
'{+half}' => '50%25',
'{base}index' => 'http%3A%2F%2Fexample.com%2Fhome%2Findex',
'{+base}index' => 'http://example.com/home/index',
'O{+empty}X' => 'OX',
'O{+undef}X' => 'OX',
'{+path}/here' => '/foo/bar/here',
'here?ref={+path}' => 'here?ref=/foo/bar',
'up{+path}{var}/here' => 'up/foo/barvalue/here',
'{+x,hello,y}' => '1024,Hello%20World!,768',
'{+path,x}/here' => '/foo/bar,1024/here',
'{+path:6}/here' => '/foo/b/here',
'{+list}' => 'red,green,blue',
'{+list*}' => 'red,green,blue',
'{+keys}' => [
'semi,;,dot,.,comma,,',
'dot,.,semi,;,comma,,',
'comma,,,semi,;,dot,.',
'semi,;,comma,,,dot,.',
'dot,.,comma,,,semi,;',
'comma,,,dot,.,semi,;'
],
'{+keys*}' => [
'semi=;,dot=.,comma=,',
'dot=.,semi=;,comma=,',
'comma=,,semi=;,dot=.',
'semi=;,comma=,,dot=.',
'dot=.,comma=,,semi=;',
'comma=,,dot=.,semi=;'
]
}
end
context "fragment expansion (#)" do
it_behaves_like 'expands', {
'{#var}' => '#value',
'{#hello}' => '#Hello%20World!',
'{#half}' => '#50%25',
'foo{#empty}' => 'foo#',
'foo{#undef}' => 'foo',
'{#x,hello,y}' => '#1024,Hello%20World!,768',
'{#path,x}/here' => '#/foo/bar,1024/here',
'{#path:6}/here' => '#/foo/b/here',
'{#list}' => '#red,green,blue',
'{#list*}' => '#red,green,blue',
'{#keys}' => [
'#semi,;,dot,.,comma,,',
'#dot,.,semi,;,comma,,',
'#comma,,,semi,;,dot,.',
'#semi,;,comma,,,dot,.',
'#dot,.,comma,,,semi,;',
'#comma,,,dot,.,semi,;'
],
'{#keys*}' => [
'#semi=;,dot=.,comma=,',
'#dot=.,semi=;,comma=,',
'#comma=,,semi=;,dot=.',
'#semi=;,comma=,,dot=.',
'#dot=.,comma=,,semi=;',
'#comma=,,dot=.,semi=;'
]
}
end
context "label expansion (.)" do
it_behaves_like 'expands', {
'{.who}' => '.fred',
'{.who,who}' => '.fred.fred',
'{.half,who}' => '.50%25.fred',
'www{.dom*}' => 'www.example.com',
'X{.var}' => 'X.value',
'X{.empty}' => 'X.',
'X{.undef}' => 'X',
'X{.var:3}' => 'X.val',
'X{.list}' => 'X.red,green,blue',
'X{.list*}' => 'X.red.green.blue',
'X{.keys}' => [
'X.semi,%3B,dot,.,comma,%2C',
'X.dot,.,semi,%3B,comma,%2C',
'X.comma,%2C,semi,%3B,dot,.',
'X.semi,%3B,comma,%2C,dot,.',
'X.dot,.,comma,%2C,semi,%3B',
'X.comma,%2C,dot,.,semi,%3B'
],
'X{.keys*}' => [
'X.semi=%3B.dot=..comma=%2C',
'X.dot=..semi=%3B.comma=%2C',
'X.comma=%2C.semi=%3B.dot=.',
'X.semi=%3B.comma=%2C.dot=.',
'X.dot=..comma=%2C.semi=%3B',
'X.comma=%2C.dot=..semi=%3B'
],
'X{.empty_keys}' => 'X',
'X{.empty_keys*}' => 'X'
}
end
context "path expansion (/)" do
it_behaves_like 'expands', {
'{/who}' => '/fred',
'{/who,who}' => '/fred/fred',
'{/half,who}' => '/50%25/fred',
'{/who,dub}' => '/fred/me%2Ftoo',
'{/var}' => '/value',
'{/var,empty}' => '/value/',
'{/var,undef}' => '/value',
'{/var,x}/here' => '/value/1024/here',
'{/var:1,var}' => '/v/value',
'{/list}' => '/red,green,blue',
'{/list*}' => '/red/green/blue',
'{/list*,path:4}' => '/red/green/blue/%2Ffoo',
'{/keys}' => [
'/semi,%3B,dot,.,comma,%2C',
'/dot,.,semi,%3B,comma,%2C',
'/comma,%2C,semi,%3B,dot,.',
'/semi,%3B,comma,%2C,dot,.',
'/dot,.,comma,%2C,semi,%3B',
'/comma,%2C,dot,.,semi,%3B'
],
'{/keys*}' => [
'/semi=%3B/dot=./comma=%2C',
'/dot=./semi=%3B/comma=%2C',
'/comma=%2C/semi=%3B/dot=.',
'/semi=%3B/comma=%2C/dot=.',
'/dot=./comma=%2C/semi=%3B',
'/comma=%2C/dot=./semi=%3B'
]
}
end
context "path-style expansion (;)" do
it_behaves_like 'expands', {
'{;who}' => ';who=fred',
'{;half}' => ';half=50%25',
'{;empty}' => ';empty',
'{;v,empty,who}' => ';v=6;empty;who=fred',
'{;v,bar,who}' => ';v=6;who=fred',
'{;x,y}' => ';x=1024;y=768',
'{;x,y,empty}' => ';x=1024;y=768;empty',
'{;x,y,undef}' => ';x=1024;y=768',
'{;hello:5}' => ';hello=Hello',
'{;list}' => ';list=red,green,blue',
'{;list*}' => ';list=red;list=green;list=blue',
'{;keys}' => [
';keys=semi,%3B,dot,.,comma,%2C',
';keys=dot,.,semi,%3B,comma,%2C',
';keys=comma,%2C,semi,%3B,dot,.',
';keys=semi,%3B,comma,%2C,dot,.',
';keys=dot,.,comma,%2C,semi,%3B',
';keys=comma,%2C,dot,.,semi,%3B'
],
'{;keys*}' => [
';semi=%3B;dot=.;comma=%2C',
';dot=.;semi=%3B;comma=%2C',
';comma=%2C;semi=%3B;dot=.',
';semi=%3B;comma=%2C;dot=.',
';dot=.;comma=%2C;semi=%3B',
';comma=%2C;dot=.;semi=%3B'
]
}
end
context "form query expansion (?)" do
it_behaves_like 'expands', {
'{?who}' => '?who=fred',
'{?half}' => '?half=50%25',
'{?x,y}' => '?x=1024&y=768',
'{?x,y,empty}' => '?x=1024&y=768&empty=',
'{?x,y,undef}' => '?x=1024&y=768',
'{?var:3}' => '?var=val',
'{?list}' => '?list=red,green,blue',
'{?list*}' => '?list=red&list=green&list=blue',
'{?keys}' => [
'?keys=semi,%3B,dot,.,comma,%2C',
'?keys=dot,.,semi,%3B,comma,%2C',
'?keys=comma,%2C,semi,%3B,dot,.',
'?keys=semi,%3B,comma,%2C,dot,.',
'?keys=dot,.,comma,%2C,semi,%3B',
'?keys=comma,%2C,dot,.,semi,%3B'
],
'{?keys*}' => [
'?semi=%3B&dot=.&comma=%2C',
'?dot=.&semi=%3B&comma=%2C',
'?comma=%2C&semi=%3B&dot=.',
'?semi=%3B&comma=%2C&dot=.',
'?dot=.&comma=%2C&semi=%3B',
'?comma=%2C&dot=.&semi=%3B'
]
}
end
context "form query expansion (&)" do
it_behaves_like 'expands', {
'{&who}' => '&who=fred',
'{&half}' => '&half=50%25',
'?fixed=yes{&x}' => '?fixed=yes&x=1024',
'{&x,y,empty}' => '&x=1024&y=768&empty=',
'{&x,y,undef}' => '&x=1024&y=768',
'{&var:3}' => '&var=val',
'{&list}' => '&list=red,green,blue',
'{&list*}' => '&list=red&list=green&list=blue',
'{&keys}' => [
'&keys=semi,%3B,dot,.,comma,%2C',
'&keys=dot,.,semi,%3B,comma,%2C',
'&keys=comma,%2C,semi,%3B,dot,.',
'&keys=semi,%3B,comma,%2C,dot,.',
'&keys=dot,.,comma,%2C,semi,%3B',
'&keys=comma,%2C,dot,.,semi,%3B'
],
'{&keys*}' => [
'&semi=%3B&dot=.&comma=%2C',
'&dot=.&semi=%3B&comma=%2C',
'&comma=%2C&semi=%3B&dot=.',
'&semi=%3B&comma=%2C&dot=.',
'&dot=.&comma=%2C&semi=%3B',
'&comma=%2C&dot=.&semi=%3B'
]
}
end
end
class ExampleTwoProcessor
def self.restore(name, value)
return value.gsub(/-/, " ") if name == "query"
return value
end
def self.match(name)
return ".*?" if name == "first"
return ".*"
end
def self.validate(name, value)
return !!(value =~ /^[\w ]+$/) if name == "query"
return true
end
def self.transform(name, value)
return value.gsub(/ /, "+") if name == "query"
return value
end
end
describe Addressable::Template do
describe "Matching" do
let(:uri){
Addressable::URI.parse(
"http://example.com/search/an-example-search-query/"
)
}
let(:uri2){
Addressable::URI.parse("http://example.com/a/b/c/")
}
let(:uri3){
Addressable::URI.parse("http://example.com/;a=1;b=2;c=3;first=foo")
}
let(:uri4){
Addressable::URI.parse("http://example.com/?a=1&b=2&c=3&first=foo")
}
context "first uri with ExampleTwoProcessor" do
subject{
match = Addressable::Template.new(
"http://example.com/search/{query}/"
).match(uri, ExampleTwoProcessor)
}
its(:variables){ should == ["query"]}
its(:captures){ should == ["an example search query"]}
end
context "second uri with ExampleTwoProcessor" do
subject{
match = Addressable::Template.new(
"http://example.com/{first}/{+second}/"
).match(uri2, ExampleTwoProcessor)
}
its(:variables){ should == ["first", "second"]}
its(:captures){ should == ["a", "b/c"] }
end
context "second uri" do
subject{
match = Addressable::Template.new(
"http://example.com/{first}{/second*}/"
).match(uri2)
}
its(:variables){ should == ["first", "second"]}
its(:captures){ should == ["a", ["b","c"]] }
end
context "third uri" do
subject{
match = Addressable::Template.new(
"http://example.com/{;hash*,first}"
).match(uri3)
}
its(:variables){ should == ["hash", "first"]}
its(:captures){ should == [
{"a" => "1", "b" => "2", "c" => "3", "first" => "foo"}, nil] }
end
context "fourth uri" do
subject{
match = Addressable::Template.new(
"http://example.com/{?hash*,first}"
).match(uri4)
}
its(:variables){ should == ["hash", "first"]}
its(:captures){ should == [
{"a" => "1", "b" => "2", "c" => "3", "first"=> "foo"}, nil] }
end
end
describe "extract" do
let(:template) {
Addressable::Template.new(
"http://{host}{/segments*}/{?one,two,bogus}{#fragment}"
)
}
let(:uri){ "http://example.com/a/b/c/?one=1&two=2#foo" }
it "should be able to extract" do
template.extract(uri).should == {
"host" => "example.com",
"segments" => %w(a b c),
"one" => "1",
"bogus" => nil,
"two" => "2",
"fragment" => "foo"
}
end
end
describe "Partial expand" do
context "partial_expand with two simple values" do
subject{
Addressable::Template.new("http://example.com/{one}/{two}/")
}
it "builds a new pattern" do
subject.partial_expand("one" => "1").pattern.should ==
"http://example.com/1/{two}/"
end
end
context "partial_expand query with missing param in middle" do
subject{
Addressable::Template.new("http://example.com/{?one,two,three}/")
}
it "builds a new pattern" do
subject.partial_expand("one" => "1", "three" => "3").pattern.should ==
"http://example.com/?one=1{&two}&three=3/"
end
end
context "partial_expand with query string" do
subject{
Addressable::Template.new("http://example.com/{?two,one}/")
}
it "builds a new pattern" do
subject.partial_expand("one" => "1").pattern.should ==
"http://example.com/{?two}&one=1/"
end
end
context "partial_expand with path operator" do
subject{
Addressable::Template.new("http://example.com{/one,two}/")
}
it "builds a new pattern" do
subject.partial_expand("one" => "1").pattern.should ==
"http://example.com/1{/two}/"
end
end
end
describe "Expand" do
context "expand with a processor" do
subject{
Addressable::Template.new("http://example.com/search/{query}/")
}
it "processes spaces" do
subject.expand({"query" => "an example search query"},
ExampleTwoProcessor).to_str.should ==
"http://example.com/search/an+example+search+query/"
end
it "validates" do
lambda{
subject.expand({"query" => "Bogus!"},
ExampleTwoProcessor).to_str
}.should raise_error(Addressable::Template::InvalidTemplateValueError)
end
end
context "partial_expand query with missing param in middle" do
subject{
Addressable::Template.new("http://example.com/{?one,two,three}/")
}
it "builds a new pattern" do
subject.partial_expand("one" => "1", "three" => "3").pattern.should ==
"http://example.com/?one=1{&two}&three=3/"
end
end
context "partial_expand with query string" do
subject{
Addressable::Template.new("http://example.com/{?two,one}/")
}
it "builds a new pattern" do
subject.partial_expand("one" => "1").pattern.should ==
"http://example.com/{?two}&one=1/"
end
end
context "partial_expand with path operator" do
subject{
Addressable::Template.new("http://example.com{/one,two}/")
}
it "builds a new pattern" do
subject.partial_expand("one" => "1").pattern.should ==
"http://example.com/1{/two}/"
end
end
end
context "Matching with operators" do
describe "Level 1:" do
subject { Addressable::Template.new("foo{foo}/{bar}baz") }
it "can match" do
data = subject.match("foofoo/bananabaz")
data.mapping["foo"].should == "foo"
data.mapping["bar"].should == "banana"
end
it "can fail" do
subject.match("bar/foo").should be_nil
subject.match("foobaz").should be_nil
end
it "can match empty" do
data = subject.match("foo/baz")
data.mapping["foo"].should == ""
data.mapping["bar"].should == ""
end
it "lists vars" do
subject.variables.should == ["foo", "bar"]
end
end
describe "Level 2:" do
subject { Addressable::Template.new("foo{+foo}{#bar}baz") }
it "can match" do
data = subject.match("foo/test/banana#bazbaz")
data.mapping["foo"].should == "/test/banana"
data.mapping["bar"].should == "baz"
end
it "lists vars" do
subject.variables.should == ["foo", "bar"]
end
end
describe "Level 3:" do
context "no operator" do
subject { Addressable::Template.new("foo{foo,bar}baz") }
it "can match" do
data = subject.match("foofoo,barbaz")
data.mapping["foo"].should == "foo"
data.mapping["bar"].should == "bar"
end
it "lists vars" do
subject.variables.should == ["foo", "bar"]
end
end
context "+ operator" do
subject { Addressable::Template.new("foo{+foo,bar}baz") }
it "can match" do
data = subject.match("foofoo/bar,barbaz")
data.mapping["bar"].should == "foo/bar,bar"
data.mapping["foo"].should == ""
end
it "lists vars" do
subject.variables.should == ["foo", "bar"]
end
end
context ". operator" do
subject { Addressable::Template.new("foo{.foo,bar}baz") }
it "can match" do
data = subject.match("foo.foo.barbaz")
data.mapping["foo"].should == "foo"
data.mapping["bar"].should == "bar"
end
it "lists vars" do
subject.variables.should == ["foo", "bar"]
end
end
context "/ operator" do
subject { Addressable::Template.new("foo{/foo,bar}baz") }
it "can match" do
data = subject.match("foo/foo/barbaz")
data.mapping["foo"].should == "foo"
data.mapping["bar"].should == "bar"
end
it "lists vars" do
subject.variables.should == ["foo", "bar"]
end
end
context "; operator" do
subject { Addressable::Template.new("foo{;foo,bar,baz}baz") }
it "can match" do
data = subject.match("foo;foo=bar%20baz;bar=foo;bazbaz")
data.mapping["foo"].should == "bar baz"
data.mapping["bar"].should == "foo"
data.mapping["baz"].should == ""
end
it "lists vars" do
subject.variables.should == %w(foo bar baz)
end
end
context "? operator" do
context "test" do
subject { Addressable::Template.new("foo{?foo,bar}baz") }
it "can match" do
data = subject.match("foo?foo=bar%20baz&bar=foobaz")
data.mapping["foo"].should == "bar baz"
data.mapping["bar"].should == "foo"
end
it "lists vars" do
subject.variables.should == %w(foo bar)
end
end
context "issue #71" do
subject { Addressable::Template.new("http://cyberscore.dev/api/users{?username}") }
it "can match" do
data = subject.match("http://cyberscore.dev/api/users?username=foobaz")
data.mapping["username"].should == "foobaz"
end
it "lists vars" do
subject.variables.should == %w(username)
subject.keys.should == %w(username)
end
end
end
context "& operator" do
subject { Addressable::Template.new("foo{&foo,bar}baz") }
it "can match" do
data = subject.match("foo&foo=bar%20baz&bar=foobaz")
data.mapping["foo"].should == "bar baz"
data.mapping["bar"].should == "foo"
end
it "lists vars" do
subject.variables.should == %w(foo bar)
end
end
end
end
context "support regexes:" do
context "EXPRESSION" do
subject { Addressable::Template::EXPRESSION }
it "should be able to match an expression" do
subject.should match("{foo}")
subject.should match("{foo,9}")
subject.should match("{foo.bar,baz}")
subject.should match("{+foo.bar,baz}")
subject.should match("{foo,foo%20bar}")
subject.should match("{#foo:20,baz*}")
subject.should match("stuff{#foo:20,baz*}things")
end
it "should fail on non vars" do
subject.should_not match("!{foo")
subject.should_not match("{foo.bar.}")
subject.should_not match("!{}")
end
end
context "VARNAME" do
subject { Addressable::Template::VARNAME }
it "should be able to match a variable" do
subject.should match("foo")
subject.should match("9")
subject.should match("foo.bar")
subject.should match("foo_bar")
subject.should match("foo_bar.baz")
subject.should match("foo%20bar")
subject.should match("foo%20bar.baz")
end
it "should fail on non vars" do
subject.should_not match("!foo")
subject.should_not match("foo.bar.")
subject.should_not match("foo%2%00bar")
subject.should_not match("foo_ba%r")
subject.should_not match("foo_bar*")
subject.should_not match("foo_bar:20")
end
end
context "VARIABLE_LIST" do
subject { Addressable::Template::VARIABLE_LIST }
it "should be able to match a variable list" do
subject.should match("foo,bar")
subject.should match("foo")
subject.should match("foo,bar*,baz")
subject.should match("foo.bar,bar_baz*,baz:12")
end
it "should fail on non vars" do
subject.should_not match(",foo,bar*,baz")
subject.should_not match("foo,*bar,baz")
subject.should_not match("foo,,bar*,baz")
end
end
context "VARSPEC" do
subject { Addressable::Template::VARSPEC }
it "should be able to match a variable with modifier" do
subject.should match("9:8")
subject.should match("foo.bar*")
subject.should match("foo_bar:12")
subject.should match("foo_bar.baz*")
subject.should match("foo%20bar:12")
subject.should match("foo%20bar.baz*")
end
it "should fail on non vars" do
subject.should_not match("!foo")
subject.should_not match("*foo")
subject.should_not match("fo*o")
subject.should_not match("fo:o")
subject.should_not match("foo:")
end
end
end
end
describe Addressable::Template::MatchData do
let(:template) { Addressable::Template.new('{foo}/{bar}') }
subject(:its) { template.match('ab/cd') }
its(:uri) { should == Addressable::URI.parse('ab/cd') }
its(:template) { should == template }
its(:mapping) { should == { 'foo' => 'ab', 'bar' => 'cd' } }
its(:variables) { should == ['foo', 'bar'] }
its(:keys) { should == its.variables }
its(:names) { should == its.variables }
its(:values) { should == ['ab', 'cd'] }
its(:captures) { should == its.values }
its(:to_a) { should == ['ab/cd', 'ab', 'cd'] }
its(:to_s) { should == 'ab/cd' }
its(:string) { should == its.to_s }
its(:pre_match) { should == "" }
its(:post_match) { should == "" }
describe 'values_at' do
it 'returns an array with the values' do
its.values_at(0, 2).should == ['ab/cd', 'cd']
end
it 'allows mixing integer an string keys' do
its.values_at('foo', 1).should == ['ab', 'ab']
end
it 'accepts unknown keys' do
its.values_at('baz', 'foo').should == [nil, 'ab']
end
end
describe '[]' do
context 'string key' do
it 'returns the corresponding capture' do
its['foo'].should == 'ab'
its['bar'].should == 'cd'
end
it 'returns nil for unknown keys' do
its['baz'].should be_nil
end
end
context 'symbol key' do
it 'returns the corresponding capture' do
its[:foo].should == 'ab'
its[:bar].should == 'cd'
end
it 'returns nil for unknown keys' do
its[:baz].should be_nil
end
end
context 'integer key' do
it 'returns the full URI for index 0' do
its[0].should == 'ab/cd'
end
it 'returns the corresponding capture' do
its[1].should == 'ab'
its[2].should == 'cd'
end
it 'returns nil for unknown keys' do
its[3].should be_nil
end
end
context 'other key' do
it 'raises an exception' do
expect { its[Object.new] }.to raise_error(TypeError)
end
end
context 'with length' do
it 'returns an array starting at index with given length' do
its[0, 2].should == ['ab/cd', 'ab']
its[2, 1].should == ['cd']
end
end
end
end
addressable-2.3.4/spec/addressable/net_http_compat_spec.rb 0000644 0000041 0000041 00000001556 12146365675 024001 0 ustar www-data www-data # coding: utf-8
# Copyright (C) 2006-2011 Bob Aman
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
require "addressable/uri"
require "net/http"
describe Net::HTTP do
it "should be compatible with Addressable" do
response_body =
Net::HTTP.get(Addressable::URI.parse('http://www.google.com/'))
response_body.should_not be_nil
end
end
addressable-2.3.4/LICENSE.txt 0000644 0000041 0000041 00000025143 12146365675 015670 0 ustar www-data www-data
Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
1. Definitions.
"License" shall mean the terms and conditions for use, reproduction,
and distribution as defined by Sections 1 through 9 of this document.
"Licensor" shall mean the copyright owner or entity authorized by
the copyright owner that is granting the License.
"Legal Entity" shall mean the union of the acting entity and all
other entities that control, are controlled by, or are under common
control with that entity. For the purposes of this definition,
"control" means (i) the power, direct or indirect, to cause the
direction or management of such entity, whether by contract or
otherwise, or (ii) ownership of fifty percent (50%) or more of the
outstanding shares, or (iii) beneficial ownership of such entity.
"You" (or "Your") shall mean an individual or Legal Entity
exercising permissions granted by this License.
"Source" form shall mean the preferred form for making modifications,
including but not limited to software source code, documentation
source, and configuration files.
"Object" form shall mean any form resulting from mechanical
transformation or translation of a Source form, including but
not limited to compiled object code, generated documentation,
and conversions to other media types.
"Work" shall mean the work of authorship, whether in Source or
Object form, made available under the License, as indicated by a
copyright notice that is included in or attached to the work
(an example is provided in the Appendix below).
"Derivative Works" shall mean any work, whether in Source or Object
form, that is based on (or derived from) the Work and for which the
editorial revisions, annotations, elaborations, or other modifications
represent, as a whole, an original work of authorship. For the purposes
of this License, Derivative Works shall not include works that remain
separable from, or merely link (or bind by name) to the interfaces of,
the Work and Derivative Works thereof.
"Contribution" shall mean any work of authorship, including
the original version of the Work and any modifications or additions
to that Work or Derivative Works thereof, that is intentionally
submitted to Licensor for inclusion in the Work by the copyright owner
or by an individual or Legal Entity authorized to submit on behalf of
the copyright owner. For the purposes of this definition, "submitted"
means any form of electronic, verbal, or written communication sent
to the Licensor or its representatives, including but not limited to
communication on electronic mailing lists, source code control systems,
and issue tracking systems that are managed by, or on behalf of, the
Licensor for the purpose of discussing and improving the Work, but
excluding communication that is conspicuously marked or otherwise
designated in writing by the copyright owner as "Not a Contribution."
"Contributor" shall mean Licensor and any individual or Legal Entity
on behalf of whom a Contribution has been received by Licensor and
subsequently incorporated within the Work.
2. Grant of Copyright License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
copyright license to reproduce, prepare Derivative Works of,
publicly display, publicly perform, sublicense, and distribute the
Work and such Derivative Works in Source or Object form.
3. Grant of Patent License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
(except as stated in this section) patent license to make, have made,
use, offer to sell, sell, import, and otherwise transfer the Work,
where such license applies only to those patent claims licensable
by such Contributor that are necessarily infringed by their
Contribution(s) alone or by combination of their Contribution(s)
with the Work to which such Contribution(s) was submitted. If You
institute patent litigation against any entity (including a
cross-claim or counterclaim in a lawsuit) alleging that the Work
or a Contribution incorporated within the Work constitutes direct
or contributory patent infringement, then any patent licenses
granted to You under this License for that Work shall terminate
as of the date such litigation is filed.
4. Redistribution. You may reproduce and distribute copies of the
Work or Derivative Works thereof in any medium, with or without
modifications, and in Source or Object form, provided that You
meet the following conditions:
(a) You must give any other recipients of the Work or
Derivative Works a copy of this License; and
(b) You must cause any modified files to carry prominent notices
stating that You changed the files; and
(c) You must retain, in the Source form of any Derivative Works
that You distribute, all copyright, patent, trademark, and
attribution notices from the Source form of the Work,
excluding those notices that do not pertain to any part of
the Derivative Works; and
(d) If the Work includes a "NOTICE" text file as part of its
distribution, then any Derivative Works that You distribute must
include a readable copy of the attribution notices contained
within such NOTICE file, excluding those notices that do not
pertain to any part of the Derivative Works, in at least one
of the following places: within a NOTICE text file distributed
as part of the Derivative Works; within the Source form or
documentation, if provided along with the Derivative Works; or,
within a display generated by the Derivative Works, if and
wherever such third-party notices normally appear. The contents
of the NOTICE file are for informational purposes only and
do not modify the License. You may add Your own attribution
notices within Derivative Works that You distribute, alongside
or as an addendum to the NOTICE text from the Work, provided
that such additional attribution notices cannot be construed
as modifying the License.
You may add Your own copyright statement to Your modifications and
may provide additional or different license terms and conditions
for use, reproduction, or distribution of Your modifications, or
for any such Derivative Works as a whole, provided Your use,
reproduction, and distribution of the Work otherwise complies with
the conditions stated in this License.
5. Submission of Contributions. Unless You explicitly state otherwise,
any Contribution intentionally submitted for inclusion in the Work
by You to the Licensor shall be under the terms and conditions of
this License, without any additional terms or conditions.
Notwithstanding the above, nothing herein shall supersede or modify
the terms of any separate license agreement you may have executed
with Licensor regarding such Contributions.
6. Trademarks. This License does not grant permission to use the trade
names, trademarks, service marks, or product names of the Licensor,
except as required for reasonable and customary use in describing the
origin of the Work and reproducing the content of the NOTICE file.
7. Disclaimer of Warranty. Unless required by applicable law or
agreed to in writing, Licensor provides the Work (and each
Contributor provides its Contributions) on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
implied, including, without limitation, any warranties or conditions
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
PARTICULAR PURPOSE. You are solely responsible for determining the
appropriateness of using or redistributing the Work and assume any
risks associated with Your exercise of permissions under this License.
8. Limitation of Liability. In no event and under no legal theory,
whether in tort (including negligence), contract, or otherwise,
unless required by applicable law (such as deliberate and grossly
negligent acts) or agreed to in writing, shall any Contributor be
liable to You for damages, including any direct, indirect, special,
incidental, or consequential damages of any character arising as a
result of this License or out of the use or inability to use the
Work (including but not limited to damages for loss of goodwill,
work stoppage, computer failure or malfunction, or any and all
other commercial damages or losses), even if such Contributor
has been advised of the possibility of such damages.
9. Accepting Warranty or Additional Liability. While redistributing
the Work or Derivative Works thereof, You may choose to offer,
and charge a fee for, acceptance of support, warranty, indemnity,
or other liability obligations and/or rights consistent with this
License. However, in accepting such obligations, You may act only
on Your own behalf and on Your sole responsibility, not on behalf
of any other Contributor, and only if You agree to indemnify,
defend, and hold each Contributor harmless for any liability
incurred by, or claims asserted against, such Contributor by reason
of your accepting any such warranty or additional liability.
END OF TERMS AND CONDITIONS
APPENDIX: How to apply the Apache License to your work.
To apply the Apache License to your work, attach the following
boilerplate notice, with the fields enclosed by brackets "[]"
replaced with your own identifying information. (Don't include
the brackets!) The text should be enclosed in the appropriate
comment syntax for the file format. We also recommend that a
file or class name and description of purpose be included on the
same "printed page" as the copyright notice for easier
identification within third-party archives.
Copyright [yyyy] [name of copyright owner]
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
addressable-2.3.4/data/ 0000755 0000041 0000041 00000000000 12146365675 014751 5 ustar www-data www-data addressable-2.3.4/data/unicode.data 0000644 0000041 0000041 00000342034 12146365675 017240 0 ustar www-data www-data {iF[i i 000if0iG[i i 000ig0iH[i i 000ih0iI[i i 000ii0iJ[i i 000ij0iK[i i 000ik0iL[i i 000il0iM[i i 000im0iN[i i 000in0iO[i i 000io0iP[i i 000ip0iQ[i i 000iq0iR[i i 000ir0iS[i i 000is0iT[i i 000it0iU[i i 000iu0iV[i i 000iv0iW[i i 000iw0iX[i i 000ix0iY[i i 000iy0iZ[i i 000iz0i[[i i 000i{0i\[i i 000i|0i][i i 000i}0i^[i i 000i~0i_[i i 000i0if[i i 00iF0iFig[i i 00iG0iGih[i i 00iH0iHii[i i 00iI0iIij[i i 00iJ0iJik[i i 00iK0iKil[i i 00iL0iLim[i i 00iM0iMin[i i 00iN0iNio[i i 00iO0iOip[i i 00iP0iPiq[i i 00iQ0iQir[i i 00iR0iRis[i i 00iS0iSit[i i 00iT0iTiu[i i 00iU0iUiv[i i 00iV0iViw[i i 00iW0iWix[i i 00iX0iXiy[i i 00iY0iYiz[i i 00iZ0iZi{[i i 00i[0i[i|[i i 00i\0i\i}[i i 00i]0i]i~[i i 00i^0i^i[i i 00i_0i_i[i i 0I" :ET000i[i i 0I" ̈; T000i[i i 0I"a; T000i[i i 0I" ̄; T000i[i i 0I"2; T000i[i i 0I"3; T000i[i i 0I" ́; T000i[i i 0I"μ; Ti0ii[i i 0I" ̧; T000i[i i 0I"1; T000i[i i 0I"o; T000i[i i 0I"
1⁄4; T000i[i i 0I"
1⁄2; T000i[i i 0I"
3⁄4; T000i[i i I"À; TI"À; T0i0i[i i I"Á; TI"Á; T0i0i[i i I"Â; TI"Â; T0i0i[i i I"Ã; TI"Ã; T0i0i[i i I"Ä; TI"Ä; T0i0i[i i I"Å; TI"Å; T0i0i[i i 000i0i[i i I"Ç; TI"Ç; T0i0i[i i I"È; TI"È; T0i0i[i i I"É; TI"É; T0i0i[i i I"Ê; TI"Ê; T0i0i[i i I"Ë; TI"Ë; T0i0i[i i I"Ì; TI"Ì; T0i0i[i i I"Í; TI"Í; T0i0i[i i I"Î; TI"Î; T0i0i[i i I"Ï; TI"Ï; T0i0i[i i 000i0i[i i I"Ñ; TI"Ñ; T0i0i[i i I"Ò; TI"Ò; T0i0i[i i I"Ó; TI"Ó; T0i0i[i i I"Ô; TI"Ô; T0i0i[i i I"Õ; TI"Õ; T0i0i[i i I"Ö; TI"Ö; T0i0i[i i 000i0i[i i I"Ù; TI"Ù; T0i0i[i i I"Ú; TI"Ú; T0i0i[i i I"Û; TI"Û; T0i0i[i i I"Ü; TI"Ü; T0i0i[i i I"Ý; TI"Ý; T0i0i[i i 000i0i[i i I"à; TI"à; Ti0ii[i i I"á; TI"á; Ti0ii[i i I"â; TI"â; Ti0ii[i i I"ã; TI"ã; Ti0ii[i i I"ä; TI"ä; Ti0ii[i i I"å; TI"å; Ti0ii[i i 00i0ii[i i I"ç; TI"ç; Ti0ii[i i I"è; TI"è; Ti0ii[i i I"é; TI"é; Ti0ii[i i I"ê; TI"ê; Ti0ii[i i I"ë; TI"ë; Ti0ii[i i I"ì; TI"ì; Ti0ii[i i I"í; TI"í; Ti0ii[i i I"î; TI"î; Ti0ii[i i I"ï; TI"ï; Ti0ii[i i 00i0ii[i i I"ñ; TI"ñ; Ti0ii[i i I"ò; TI"ò; Ti0ii[i i I"ó; TI"ó; Ti0ii[i i I"ô; TI"ô; Ti0ii[i i I"õ; TI"õ; Ti0ii[i i I"ö; TI"ö; Ti0ii[i i 00i0ii[i i I"ù; TI"ù; Ti0ii[i i I"ú; TI"ú; Ti0ii[i i I"û; TI"û; Ti0ii[i i I"ü; TI"ü; Ti0ii[i i I"ý; TI"ý; Ti0ii[i i 00i0ii[i i I"ÿ; TI"ÿ; Tix0ixi [i i I"Ā; TI"Ā; T0i0i[i i I"ā; TI"ā; Ti 0i i[i i I"Ă; TI"Ă; T0i0i[i i I"ă; TI"ă; Ti0ii[i i I"Ą; TI"Ą; T0i0i[i i I"ą; TI"ą; Ti0ii[i i I"Ć; TI"Ć; T0i0i[i i I"ć; TI"ć; Ti0ii[i i I"Ĉ; TI"Ĉ; T0i 0i [i i I"ĉ; TI"ĉ; Ti0ii
[i i I"Ċ; TI"Ċ; T0i0i[i i I"ċ; TI"ċ; Ti
0i
i[i i I"Č; TI"Č; T0i
0i
[i i I"č; TI"č; Ti0ii[i i I"Ď; TI"Ď; T0i0i[i i I"ď; TI"ď; Ti0ii[i i 000i0i[i i 00i0ii[i i I"Ē; TI"Ē; T0i0i[i i I"ē; TI"ē; Ti0ii[i i I"Ĕ; TI"Ĕ; T0i0i[i i I"ĕ; TI"ĕ; Ti0ii[i i I"Ė; TI"Ė; T0i0i[i i I"ė; TI"ė; Ti0ii[i i I"Ę; TI"Ę; T0i0i[i i I"ę; TI"ę; Ti0ii[i i I"Ě; TI"Ě; T0i0i[i i I"ě; TI"ě; Ti0ii[i i I"Ĝ; TI"Ĝ; T0i0i[i i I"ĝ; TI"ĝ; Ti0ii[i i I"Ğ; TI"Ğ; T0i0i[i i I"ğ; TI"ğ; Ti0ii [i i I"Ġ; TI"Ġ; T0i!0i![i i I"ġ; TI"ġ; Ti 0i i"[i i I"Ģ; TI"Ģ; T0i#0i#[i i I"ģ; TI"ģ; Ti"0i"i$[i i I"Ĥ; TI"Ĥ; T0i%0i%[i i I"ĥ; TI"ĥ; Ti$0i$i&[i i 000i'0i'[i i 00i&0i&i([i i I"Ĩ; TI"Ĩ; T0i)0i)[i i I"ĩ; TI"ĩ; Ti(0i(i*[i i I"Ī; TI"Ī; T0i+0i+[i i I"ī; TI"ī; Ti*0i*i,[i i I"Ĭ; TI"Ĭ; T0i-0i-[i i I"ĭ; TI"ĭ; Ti,0i,i.[i i I"Į; TI"Į; T0i/0i/[i i I"į; TI"į; Ti.0i.i0[i i I"İ; TI"İ; T0in0i1[i i 00iN0iNi2[i i 0I"IJ; T0i30i3[i i 0I"ij; Ti20i2i4[i i I"Ĵ; TI"Ĵ; T0i50i5[i i I"ĵ; TI"ĵ; Ti40i4i6[i i I"Ķ; TI"Ķ; T0i70i7[i i I"ķ; TI"ķ; Ti60i6i9[i i I"Ĺ; TI"Ĺ; T0i:0i:[i i I"ĺ; TI"ĺ; Ti90i9i;[i i I"Ļ; TI"Ļ; T0i<0i<[i i I"ļ; TI"ļ; Ti;0i;i=[i i I"Ľ; TI"Ľ; T0i>0i>[i i I"ľ; TI"ľ; Ti=0i=i?[i i 0I"L·; T0i@0i@[i i 0I"l·; Ti?0i?iA[i i 000iB0iB[i i 00iA0iAiC[i i I"Ń; TI"Ń; T0iD0iD[i i I"ń; TI"ń; TiC0iCiE[i i I"Ņ; TI"Ņ; T0iF0iF[i i I"ņ; TI"ņ; TiE0iEiG[i i I"Ň; TI"Ň; T0iH0iH[i i I"ň; TI"ň; TiG0iGiI[i i 0I"ʼn; T000iJ[i i 000iK0iK[i i 00iJ0iJiL[i i I"Ō; TI"Ō; T0iM0iM[i i I"ō; TI"ō; TiL0iLiN[i i I"Ŏ; TI"Ŏ; T0iO0iO[i i I"ŏ; TI"ŏ; TiN0iNiP[i i I"Ő; TI"Ő; T0iQ0iQ[i i I"ő; TI"ő; TiP0iPiR[i i 000iS0iS[i i 00iR0iRiT[i i I"Ŕ; TI"Ŕ; T0iU0iU[i i I"ŕ; TI"ŕ; TiT0iTiV[i i I"Ŗ; TI"Ŗ; T0iW0iW[i i I"ŗ; TI"ŗ; TiV0iViX[i i I"Ř; TI"Ř; T0iY0iY[i i I"ř; TI"ř; TiX0iXiZ[i i I"Ś; TI"Ś; T0i[0i[[i i I"ś; TI"ś; TiZ0iZi\[i i I"Ŝ; TI"Ŝ; T0i]0i][i i I"ŝ; TI"ŝ; Ti\0i\i^[i i I"Ş; TI"Ş; T0i_0i_[i i I"ş; TI"ş; Ti^0i^i`[i i I"Š; TI"Š; T0ia0ia[i i I"š; TI"š; Ti`0i`ib[i i I"Ţ; TI"Ţ; T0ic0ic[i i I"ţ; TI"ţ; Tib0ibid[i i I"Ť; TI"Ť; T0ie0ie[i i I"ť; TI"ť; Tid0idif[i i 000ig0ig[i i 00if0ifih[i i I"Ũ; TI"Ũ; T0ii0ii[i i I"ũ; TI"ũ; Tih0ihij[i i I"Ū; TI"Ū; T0ik0ik[i i I"ū; TI"ū; Tij0ijil[i i I"Ŭ; TI"Ŭ; T0im0im[i i I"ŭ; TI"ŭ; Til0ilin[i i I"Ů; TI"Ů; T0io0io[i i I"ů; TI"ů; Tin0inip[i i I"Ű; TI"Ű; T0iq0iq[i i I"ű; TI"ű; Tip0ipir[i i I"Ų; TI"Ų; T0is0is[i i I"ų; TI"ų; Tir0irit[i i I"Ŵ; TI"Ŵ; T0iu0iu[i i I"ŵ; TI"ŵ; Tit0itiv[i i I"Ŷ; TI"Ŷ; T0iw0iw[i i I"ŷ; TI"ŷ; Tiv0ivix[i i I"Ÿ; TI"Ÿ; T0i0iy[i i I"Ź; TI"Ź; T0iz0iz[i i I"ź; TI"ź; Tiy0iyi{[i i I"Ż; TI"Ż; T0i|0i|[i i I"ż; TI"ż; Ti{0i{i}[i i I"Ž; TI"Ž; T0i~0i~[i i I"ž; TI"ž; Ti}0i}i[i i 0I"s; TiX0iXi[i i 000iS0i[i i 000i0i[i i 00i0ii[i i 000i0i[i i 00i0ii[i i 000iT0i[i i 000i0i[i i 00i0ii[i i 000iV0i[i i 000iW0i[i i 000i0i[i i 00i0ii[i i 000i0i[i i 000iY0i[i i 000i[0i[i i 000i0i[i i 00i0ii[i i 000i`0i[i i 000ic0i[i i 00i0ii[i i 000ii0i[i i 000ih0i[i i 000i0i[i i 00i0ii[i i 000io0i[i i 000ir0i[i i 000iu0i[i i I"Ơ; TI"Ơ; T0i0i[i i I"ơ; TI"ơ; Ti0ii[i i 000i0i[i i 00i0ii[i i 000i0i[i i 00i0ii[i i 000i0i[i i 000i0i[i i 00i0ii[i i 000i0i[i i 000i0i[i i 00i0ii[i i 000i0i[i i I"Ư; TI"Ư; T0i0i[i i I"ư; TI"ư; Ti0ii[i i 000i0i[i i 000i0i[i i 000i0i[i i 00i0ii[i i 000i0i[i i 00i0ii[i i 000i0i[i i 000i0i[i i 00i0ii[i i 000i0i[i i 00i0ii[i i 00i0ii[i i 0I"DŽ; T0iii[i i 0I"Dž; Tii0i[i i 0I"dž; Ti0ii[i i 0I"LJ; T0iii[i i 0I"Lj; Tii0i[i i 0I"lj; Ti0ii[i i 0I"NJ; T0iii[i i 0I"Nj; Tii0i[i i 0I"nj; Ti0ii[i i I"Ǎ; TI"Ǎ; T0i0i[i i I"ǎ; TI"ǎ; Ti0ii[i i I"Ǐ; TI"Ǐ; T0i0i[i i I"ǐ; TI"ǐ; Ti0ii[i i I"Ǒ; TI"Ǒ; T0i0i[i i I"ǒ; TI"ǒ; Ti0ii[i i I"Ǔ; TI"Ǔ; T0i0i[i i I"ǔ; TI"ǔ; Ti0ii[i i I" Ǖ; TI" Ǖ; T0i0i[i i I" ǖ; TI" ǖ; Ti0ii[i i I" Ǘ; TI" Ǘ; T0i0i[i i I" ǘ; TI" ǘ; Ti0ii[i i I" Ǚ; TI" Ǚ; T0i0i[i i I" ǚ; TI" ǚ; Ti0ii[i i I" Ǜ; TI" Ǜ; T0i0i[i i I" ǜ; TI" ǜ; Ti0ii[i i 00i0ii[i i I" Ǟ; TI" Ǟ; T0i0i[i i I" ǟ; TI" ǟ; Ti0ii[i i I" Ǡ; TI" Ǡ; T0i0i[i i I" ǡ; TI" ǡ; Ti0ii[i i I" Ǣ; TI" Ǣ; T0i0i[i i I" ǣ; TI" ǣ; Ti0ii[i i 000i0i[i i 00i0ii[i i I"Ǧ; TI"Ǧ; T0i0i[i i I"ǧ; TI"ǧ; Ti0ii[i i I"Ǩ; TI"Ǩ; T0i0i[i i I"ǩ; TI"ǩ; Ti0ii[i i I"Ǫ; TI"Ǫ; T0i0i[i i I"ǫ; TI"ǫ; Ti0ii[i i I" Ǭ; TI" Ǭ; T0i0i[i i I" ǭ; TI" ǭ; Ti0ii[i i I" Ǯ; TI" Ǯ; T0i0i[i i I" ǯ; TI" ǯ; Ti0ii[i i I"ǰ; TI"ǰ; T000i[i i 0I"DZ; T0iii[i i 0I"Dz; Tii0i[i i 0I"dz; Ti0ii[i i I"Ǵ; TI"Ǵ; T0i0i[i i I"ǵ; TI"ǵ; Ti0ii[i i 000i0i[i i 000i0i[i i I"Ǹ; TI"Ǹ; T0i0i[i i I"ǹ; TI"ǹ; Ti0ii[i i I" Ǻ; TI" Ǻ; T0i0i[i i I" ǻ; TI" ǻ; Ti0ii[i i I" Ǽ; TI" Ǽ; T0i0i[i i I" ǽ; TI" ǽ; Ti0ii[i i I" Ǿ; TI" Ǿ; T0i0i[i i I" ǿ; TI" ǿ; Ti0ii [i i I"Ȁ; TI"Ȁ; T0i0i[i i I"ȁ; TI"ȁ; Ti 0i i[i i I"Ȃ; TI"Ȃ; T0i0i[i i I"ȃ; TI"ȃ; Ti0ii[i i I"Ȅ; TI"Ȅ; T0i0i[i i I"ȅ; TI"ȅ; Ti0ii[i i I"Ȇ; TI"Ȇ; T0i0i[i i I"ȇ; TI"ȇ; Ti0ii[i i I"Ȉ; TI"Ȉ; T0i 0i [i i I"ȉ; TI"ȉ; Ti0ii
[i i I"Ȋ; TI"Ȋ; T0i0i[i i I"ȋ; TI"ȋ; Ti
0i
i[i i I"Ȍ; TI"Ȍ; T0i
0i
[i i I"ȍ; TI"ȍ; Ti0ii[i i I"Ȏ; TI"Ȏ; T0i0i[i i I"ȏ; TI"ȏ; Ti0ii[i i I"Ȑ; TI"Ȑ; T0i0i[i i I"ȑ; TI"ȑ; Ti0ii[i i I"Ȓ; TI"Ȓ; T0i0i[i i I"ȓ; TI"ȓ; Ti0ii[i i I"Ȕ; TI"Ȕ; T0i0i[i i I"ȕ; TI"ȕ; Ti0ii[i i I"Ȗ; TI"Ȗ; T0i0i[i i I"ȗ; TI"ȗ; Ti0ii[i i I"Ș; TI"Ș; T0i0i[i i I"ș; TI"ș; Ti0ii[i i I"Ț; TI"Ț; T0i0i[i i I"ț; TI"ț; Ti0ii[i i 000i0i[i i 00i0ii[i i I"Ȟ; TI"Ȟ; T0i0i[i i I"ȟ; TI"ȟ; Ti0ii"[i i 000i#0i#[i i 00i"0i"i$[i i 000i%0i%[i i 00i$0i$i&[i i I"Ȧ; TI"Ȧ; T0i'0i'[i i I"ȧ; TI"ȧ; Ti&0i&i([i i I"Ȩ; TI"Ȩ; T0i)0i)[i i I"ȩ; TI"ȩ; Ti(0i(i*[i i I" Ȫ; TI" Ȫ; T0i+0i+[i i I" ȫ; TI" ȫ; Ti*0i*i,[i i I" Ȭ; TI" Ȭ; T0i-0i-[i i I" ȭ; TI" ȭ; Ti,0i,i.[i i I"Ȯ; TI"Ȯ; T0i/0i/[i i I"ȯ; TI"ȯ; Ti.0i.i0[i i I" Ȱ; TI" Ȱ; T0i10i1[i i I" ȱ; TI" ȱ; Ti00i0i2[i i I"Ȳ; TI"Ȳ; T0i30i3[i i I"ȳ; TI"ȳ; Ti20i2iS[i i 00i0iiT[i i 00i0iiV[i i 00i0iiW[i i 00i0iiY[i i 00i0ii[[i i 00i0ii`[i i 00i0iic[i i 00i0iih[i i 00i0iii[i i 00i0iio[i i 00i0iir[i i 00i0iiu[i i 00i0ii[i i 00i0ii[i i 00i0ii[i i 00i0ii[i i 00i0ii[i i 00i0ii[i i 00i0ii[i i 0I"h; T000i[i i 0I"ɦ; T000i[i i 0I"j; T000i[i i 0I"r; T000i[i i 0I"ɹ; T000i[i i 0I"ɻ; T000i[i i 0I"ʁ; T000i[i i 0I"w; T000i[i i 0I"y; T000i[i i 0I" ̆; T000i[i i 0I" ̇; T000i[i i 0I" ̊; T000i[i i 0I" ̨; T000i[i i 0I" ̃; T000i[i i 0I" ̋; T000i[i i 0I"ɣ; T000i[i i 0I"l; T000i[i i 0I"s; T000i[i i 0I"x; T000i[i i 0I"ʕ; T000i [ii 00000i[ii 00000i[ii 00000i[ii 00000i[ii 00000i[ii 00000i[ii 00000i[ii 00000i[ii 00000i [ii 00000i
[ii 00000i[ii 00000i[ii 00000i
[ii 00000i[ii 00000i[ii 00000i[ii 00000i[ii 00000i[ii 00000i[ii 00000i[ii 00000i[ii 00000i[ii 00000i[ii 00000i[ii 00000i[ii 00000i[ii 00000i[ii 00000i[ii 00000i[ii 00000i[ii 00000i[ii 00000i [ii 00000i![ii 00000i"[ii 00000i#[ii 00000i$[ii 00000i%[ii 00000i&[ii 00000i'[ii 00000i([ii 00000i)[ii 00000i*[ii 00000i+[ii 00000i,[ii 00000i-[ii 00000i.[ii 00000i/[ii 00000i0[ii 00000i1[ii 00000i2[ii 00000i3[ii 00000i4[ii 00000i5[ii 00000i6[ii 00000i7[ii 00000i8[ii 00000i9[ii 00000i:[ii 00000i;[ii 00000i<[ii 00000i=[ii 00000i>[ii 00000i?[ii 00000i@[iiI"̀; TI"̀; T000iA[iiI"́; TI"́; T000iB[ii 00000iC[iiI"̓; TI"̓; T000iD[iiI" ̈́; TI" ̈́; T000iE[ii 00i0iiF[ii 00000iG[ii 00000iH[ii 00000iI[ii 00000iJ[ii 00000iK[ii 00000iL[ii 00000iM[ii 00000iN[ii 00000i`[ii 00000ia[ii 00000ib[ii 00000it[i iI"ʹ; TI"ʹ; T000iz[i i 0I" ͅ; T000i~[i iI";; TI";; T000i[i i 0I" ́; T000i[i i I" ΅; TI" ΅; T000i[i i I" Ά; TI" Ά; T0i0i[i iI"·; TI"·; T000i[i i I" Έ; TI" Έ; T0i0i[i i I" Ή; TI" Ή; T0i0i[i i I" Ί; TI" Ί; T0i0i[i i I" Ό; TI" Ό; T0i0i[i i I" Ύ; TI" Ύ; T0i0i[i i I" Ώ; TI" Ώ; T0i0i[i i I" ΐ; TI" ΐ; T000i[i i 000i0i[i i 000i0i[i i 000i0i[i i 000i0i[i i 000i0i[i i 000i0i[i i 000i0i[i i 000i0i[i i 000i0i[i i 000i0i[i i 000i0i[i i 000i0i[i i 000i0i[i i 000i0i[i i 000i0i[i i 000i0i[i i 000i0i[i i 000i0i[i i 000i0i[i i 000i0i[i i 000i0i[i i 000i0i[i i 000i0i[i i 000i0i[i i I" Ϊ; TI" Ϊ; T0i0i[i i I" Ϋ; TI" Ϋ; T0i0i[i i I" ά; TI" ά; Ti0ii[i i I" έ; TI" έ; Ti0ii[i i I" ή; TI" ή; Ti0ii[i i I" ί; TI" ί; Ti0ii[i i I" ΰ; TI" ΰ; T000i[i i 00i0ii[i i 00i0ii[i i 00i0ii[i i 00i0ii[i i 00i0ii[i i 00i0ii[i i 00i0ii[i i 00i0ii[i i 00i0ii[i i 00i0ii[i i 00i0ii[i i 00i0ii[i i 00i0ii[i i 00i0ii[i i 00i0ii[i i 00i0ii[i i 00i0ii[i i 00i0ii[i i 00i0ii[i i 00i0ii[i i 00i0ii[i i 00i0ii[i i 00i0ii[i i 00i0ii[i i 00i0ii[i i I" ϊ; TI" ϊ; Ti0ii[i i I" ϋ; TI" ϋ; Ti0ii[i i I" ό; TI" ό; Ti0ii[i i I" ύ; TI" ύ; Ti0ii[i i I" ώ; TI" ώ; Ti0ii[i i 0I"β; Ti0ii[i i 0I"θ; Ti0ii[i i 0I"Υ; T000i[i i I" ϓ; TI" ϓ; T000i[i i I" ϔ; TI" ϔ; T000i[i i 0I"φ; Ti0ii[i i 0I"π; Ti0ii[i i 000i0i[i i 00i0ii[i i 000i0i[i i 00i0ii[i i 000i0i[i i 00i0ii[i i 000i0i[i i 00i0ii[i i 000i0i[i i 00i0ii[i i 000i0i[i i 00i0ii[i i 000i0i[i i 00i0ii[i i 000i0i[i i 00i0ii[i i 000i0i[i i 00i0ii[i i 000i0i[i i 00i0ii[i i 000i0i[i i 00i0ii[i i 0I"κ; Ti0ii[i i 0I"ρ; Ti0ii[i i 0I"ς; Ti0ii [i i I" Ѐ; TI" Ѐ; T0iP0i[i i I" Ё; TI" Ё; T0iQ0i[i i 000iR0i[i i I" Ѓ; TI" Ѓ; T0iS0i[i i 000iT0i[i i 000iU0i[i i 000iV0i[i i I" Ї; TI" Ї; T0iW0i[i i 000iX0i [i i 000iY0i
[i i 000iZ0i[i i 000i[0i[i i I" Ќ; TI" Ќ; T0i\0i
[i i I" Ѝ; TI" Ѝ; T0i]0i[i i I" Ў; TI" Ў; T0i^0i[i i 000i_0i[i i 000i00i[i i 000i10i[i i 000i20i[i i 000i30i[i i 000i40i[i i 000i50i[i i 000i60i[i i 000i70i[i i 000i80i[i i I" Й; TI" Й; T0i90i[i i 000i:0i[i i 000i;0i[i i 000i<0i[i i 000i=0i[i i 000i>0i[i i 000i?0i [i i 000i@0i![i i 000iA0i"[i i 000iB0i#[i i 000iC0i$[i i 000iD0i%[i i 000iE0i&[i i 000iF0i'[i i 000iG0i([i i 000iH0i)[i i 000iI0i*[i i 000iJ0i+[i i 000iK0i,[i i 000iL0i-[i i 000iM0i.[i i 000iN0i/[i i 000iO0i0[i i 00i0ii1[i i 00i0ii2[i i 00i0ii3[i i 00i0ii4[i i 00i0ii5[i i 00i0ii6[i i 00i0ii7[i i 00i0ii8[i i 00i0ii9[i i I" й; TI" й; Ti0ii:[i i 00i0ii;[i i 00i0ii<[i i 00i0ii=[i i 00i0ii>[i i 00i0ii?[i i 00i0ii@[i i 00i 0i iA[i i 00i!0i!iB[i i 00i"0i"iC[i i 00i#0i#iD[i i 00i$0i$iE[i i 00i%0i%iF[i i 00i&0i&iG[i i 00i'0i'iH[i i 00i(0i(iI[i i 00i)0i)iJ[i i 00i*0i*iK[i i 00i+0i+iL[i i 00i,0i,iM[i i 00i-0i-iN[i i 00i.0i.iO[i i 00i/0i/iP[i i I" ѐ; TI" ѐ; Ti 0i iQ[i i I" ё; TI" ё; Ti0iiR[i i 00i0iiS[i i I" ѓ; TI" ѓ; Ti0iiT[i i 00i0iiU[i i 00i0iiV[i i 00i0iiW[i i I" ї; TI" ї; Ti0iiX[i i 00i0iiY[i i 00i 0i iZ[i i 00i
0i
i[[i i 00i0ii\[i i I" ќ; TI" ќ; Ti0ii][i i I" ѝ; TI" ѝ; Ti
0i
i^[i i I" ў; TI" ў; Ti0ii_[i i 00i0ii`[i i 000ia0ia[i i 00i`0i`ib[i i 000ic0ic[i i 00ib0ibid[i i 000ie0ie[i i 00id0idif[i i 000ig0ig[i i 00if0ifih[i i 000ii0ii[i i 00ih0ihij[i i 000ik0ik[i i 00ij0ijil[i i 000im0im[i i 00il0ilin[i i 000io0io[i i 00in0inip[i i 000iq0iq[i i 00ip0ipir[i i 000is0is[i i 00ir0irit[i i 000iu0iu[i i 00it0itiv[i i I" Ѷ; TI" Ѷ; T0iw0iw[i i I" ѷ; TI" ѷ; Tiv0ivix[i i 000iy0iy[i i 00ix0ixiz[i i 000i{0i{[i i 00iz0izi|[i i 000i}0i}[i i 00i|0i|i~[i i 000i0i[i i 00i~0i~i[i i 000i0i[i i 00i0ii[ii 00000i[ii 00000i[ii 00000i[ii 00000i[i i 000i0i[i i 00i0ii[i i 000i0i[i i 00i0ii[i i 000i0i[i i 00i0ii[i i 000i0i[i i 00i0ii[i i 000i0i[i i 00i0ii[i i 000i0i[i i 00i0ii[i i 000i0i[i i 00i0ii[i i 000i0i[i i 00i0ii[i i 000i0i[i i 00i0ii[i i 000i0i[i i 00i0ii[i i 000i0i[i i 00i0ii[i i 000i0i[i i 00i0ii[i i 000i0i[i i 00i0ii[i i 000i0i[i i 00i0ii[i i 000i0i[i i 00i0ii[i i 000i0i[i i 00i0ii[i i 000i0i[i i 00i0ii[i i 000i0i[i i 00i0ii[i i 000i0i[i i 00i0ii[i i 000i0i[i i 00i0ii[i i 000i0i[i i 00i0ii[i i 000i0i[i i 00i0ii[i i 000i0i[i i 00i0ii[i i 000i0i[i i 00i0ii[i i 000i0i[i i 00i0ii[i i 000i0i[i i 00i0ii[i i I" Ӂ; TI" Ӂ; T0i0i[i i I" ӂ; TI" ӂ; Ti0ii[i i 000i0i[i i 00i0ii[i i 000i0i[i i 00i0ii[i i 000i0i[i i 00i0ii[i i I" Ӑ; TI" Ӑ; T0i0i[i i I" ӑ; TI" ӑ; Ti0ii[i i I" Ӓ; TI" Ӓ; T0i0i[i i I" ӓ; TI" ӓ; Ti0ii[i i 000i0i[i i 00i0ii[i i I" Ӗ; TI" Ӗ; T0i0i[i i I" ӗ; TI" ӗ; Ti0ii[i i 000i0i[i i 00i0ii[i i I" Ӛ; TI" Ӛ; T0i0i[i i I" ӛ; TI" ӛ; Ti0ii[i i I" Ӝ; TI" Ӝ; T0i0i[i i I" ӝ; TI" ӝ; Ti0ii[i i I" Ӟ; TI" Ӟ; T0i0i[i i I" ӟ; TI" ӟ; Ti0ii[i i 000i0i[i i 00i0ii[i i I" Ӣ; TI" Ӣ; T0i0i[i i I" ӣ; TI" ӣ; Ti0ii[i i I" Ӥ; TI" Ӥ; T0i0i[i i I" ӥ; TI" ӥ; Ti0ii[i i I" Ӧ; TI" Ӧ; T0i0i[i i I" ӧ; TI" ӧ; Ti0ii[i i 000i0i[i i 00i0ii[i i I" Ӫ; TI" Ӫ; T0i0i[i i I" ӫ; TI" ӫ; Ti0ii[i i I" Ӭ; TI" Ӭ; T0i0i[i i I" ӭ; TI" ӭ; Ti0ii[i i I" Ӯ; TI" Ӯ; T0i0i[i i I" ӯ; TI" ӯ; Ti0ii[i i I" Ӱ; TI" Ӱ; T0i0i[i i I" ӱ; TI" ӱ; Ti0ii[i i I" Ӳ; TI" Ӳ; T0i0i[i i I" ӳ; TI" ӳ; Ti0ii[i i I" Ӵ; TI" Ӵ; T0i0i[i i I" ӵ; TI" ӵ; Ti0ii[i i I" Ӹ; TI" Ӹ; T0i0i[i i I" ӹ; TI" ӹ; Ti0ii1[i i 000ia0i2[i i 000ib0i3[i i 000ic0i4[i i 000id0i5[i i 000ie0i6[i i 000if0i7[i i 000ig0i8[i i 000ih0i9[i i 000ii0i:[i i 000ij0i;[i i 000ik0i<[i i 000il0i=[i i 000im0i>[i i 000in0i?[i i 000io0i@[i i 000ip0iA[i i 000iq0iB[i i 000ir0iC[i i 000is0iD[i i 000it0iE[i i 000iu0iF[i i 000iv0iG[i i 000iw0iH[i i 000ix0iI[i i 000iy0iJ[i i 000iz0iK[i i 000i{0iL[i i 000i|0iM[i i 000i}0iN[i i 000i~0iO[i i 000i0iP[i i 000i0iQ[i i 000i0iR[i i 000i0iS[i i 000i0iT[i i 000i0iU[i i 000i0iV[i i 000i0ia[i i 00i10i1ib[i i 00i20i2ic[i i 00i30i3id[i i 00i40i4ie[i i 00i50i5if[i i 00i60i6ig[i i 00i70i7ih[i i 00i80i8ii[i i 00i90i9ij[i i 00i:0i:ik[i i 00i;0i;il[i i 00i<0i<im[i i 00i=0i=in[i i 00i>0i>io[i i 00i?0i?ip[i i 00i@0i@iq[i i 00iA0iAir[i i 00iB0iBis[i i 00iC0iCit[i i 00iD0iDiu[i i 00iE0iEiv[i i 00iF0iFiw[i i 00iG0iGix[i i 00iH0iHiy[i i 00iI0iIiz[i i 00iJ0iJi{[i i 00iK0iKi|[i i 00iL0iLi}[i i 00iM0iMi~[i i 00iN0iNi[i i 00iO0iOi[i i 00iP0iPi[i i 00iQ0iQi[i i 00iR0iRi[i i 00iS0iSi[i i 00iT0iTi[i i 00iU0iUi[i i 00iV0iVi[i i 0I" եւ; T000i[ii 00000i[ii 00000i[ii 00000i[ii 00000i[ii 00000i[ii 00000i[ii 00000i[ii 00000i[ii 00000i[ii 00000i[ii 00000i[ii 00000i[ii 00000i[ii 00000i[ii 00000i[ii 00000i[ii 00000i[ii 00000i[ii 00000i[ii 00000i[ii 00000i[ii 00000i[ii 00000i[ii 00000i[ii 00000i[ii 00000i[ii 00000i[ii 00000i[ii 00000i[ii 00000i[ii 00000i[ii 00000i[ii 00000i[ii 00000i[ii 00000i[ii 00000i[ii 00000i[ii 00000i[ii 00000i[ii 00000i[ii 00000i[ii 00000i[ii 00000i[ii 00000i[ii 00000i[ii 00000i[ii 00000i"[i i I" آ; TI" آ; T000i#[i i I" أ; TI" أ; T000i$[i i I" ؤ; TI" ؤ; T000i%[i i I" إ; TI" إ; T000i&[i i I" ئ; TI" ئ; T000iK[i i 00000iL[i!i 00000iM[i"i 00000iN[i#i 00000iO[i$i 00000iP[i%i 00000iQ[i&i