Addressable is an alternative implementation to the URI implementation that is part of Ruby's standard library. It is flexible, offers heuristic parsing, and additionally provides extensive support for IRIs and URI templates.
Find a file
dependabot[bot] d298c9f551
Build(deps): Bump github/codeql-action from 4.35.4 to 4.35.5 (#594)
Bumps [github/codeql-action](https://github.com/github/codeql-action) from 4.35.4 to 4.35.5.
- [Release notes](https://github.com/github/codeql-action/releases)
- [Changelog](https://github.com/github/codeql-action/blob/main/CHANGELOG.md)
- [Commits](68bde559de...9e0d7b8d25)

---
updated-dependencies:
- dependency-name: github/codeql-action
  dependency-version: 4.35.5
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2026-05-17 22:21:47 +02:00
.github Build(deps): Bump github/codeql-action from 4.35.4 to 4.35.5 (#594) 2026-05-17 22:21:47 +02:00
benchmark restore unicode_normalize_kc as a deprecated method (#504) 2023-04-09 16:46:31 +02:00
gemfiles CI: add public_suffix v7 job 2026-01-25 18:20:06 +01:00
lib This should keep the tests from being flaky on TruffleRuby 2026-04-05 00:43:08 -05:00
spec Fixing additional vulnerable paths 2026-04-04 22:39:35 -05:00
tasks No need for bundler as development dependency 2026-01-25 18:20:06 +01:00
.gitignore Fix a ReDoS vulnerability in URI template matching 2026-04-04 16:57:01 -05:00
.simplecov See if this fixes coveralls including IDN files in code coverage. 2016-11-04 11:30:57 -07:00
.yardopts Substantially updated the documentation. 2010-08-09 19:20:21 -07:00
addressable.gemspec Revving version and changelog 2026-04-04 22:39:35 -05:00
CHANGELOG.md Revving version and changelog 2026-04-04 22:39:35 -05:00
Gemfile CI: Add bigdecimal to Gemfile (#533) 2024-05-22 11:41:46 +02:00
LICENSE.txt Explicitly marking LICENSE as Text. 2012-05-02 21:57:36 +03:00
Rakefile Reduce gem size by excluding test files (#569) 2026-01-28 23:21:40 +01:00
README.md Fix heading levels in README and Changelog 2025-11-25 08:32:00 +01:00
RELEASING.md Fix link in CHANGELOG, add missing space in RELEASING (#563) 2025-11-25 08:56:03 +01:00

Addressable

Homepage
github.com/sporkmonger/addressable
Author
Bob Aman
Copyright
Copyright © Bob Aman
License
Apache 2.0

Gem Version Build Status Test Coverage Status Documentation Coverage Status

Description

Addressable is an alternative implementation to the URI implementation that is part of Ruby's standard library. It is flexible, offers heuristic parsing, and additionally provides extensive support for IRIs and URI templates.

Addressable closely conforms to RFC 3986, RFC 3987, and RFC 6570 (level 4).

Reference

  • {Addressable::URI}
  • {Addressable::Template}

Example usage

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
#=> #<Addressable::URI:0xc9a4c8 URI:http://www.xn--8ws00zhy3a.com/>

URI Templates

For more details, see RFC 6570.


require "addressable/template"

template = Addressable::Template.new("http://example.com/{?query*}")
template.expand({
  "query" => {
    'foo' => 'bar',
    'color' => 'red'
  }
})
#=> #<Addressable::URI:0xc9d95c URI:http://example.com/?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

$ gem install addressable

You may optionally turn on native IDN support by installing libidn and the idn gem:

$ sudo apt-get install libidn11-dev # Debian/Ubuntu
$ brew install libidn # OS X
$ gem install idn-ruby

Semantic Versioning

This project uses Semantic Versioning. You can (and should) specify your dependency using a pessimistic version constraint covering the major and minor values:

spec.add_dependency 'addressable', '~> 2.7'

If you need a specific bug fix, you can also specify minimum tiny versions without preventing updates to the latest minor release:

spec.add_dependency 'addressable', '~> 2.3', '>= 2.3.7'