Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: ruby/uri
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: master
Choose a base ref
...
head repository: ruby/uri
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: v0-13
Choose a head ref
Can’t automatically merge. Don’t worry, you can still create the pull request.
  • 8 commits
  • 5 files changed
  • 2 contributors

Commits on Aug 26, 2024

  1. Define RFC2396_PARSER for migrating with the development version

    hsbt committed Aug 26, 2024

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature.
    Copy the full SHA
    09a5a9e View commit details
  2. Exclude Ruby 2.5 from macos-latest that is macos-14

    hsbt committed Aug 26, 2024
    Copy the full SHA
    133e151 View commit details

Commits on Aug 27, 2024

  1. Merge pull request #119 from ruby/define-rfc2396-parser

    Define RFC2396_PARSER for Ruby 3.3
    hsbt authored Aug 27, 2024
    Copy the full SHA
    108c95c View commit details
  2. Bump up 0.13.1

    hsbt committed Aug 27, 2024
    Copy the full SHA
    56490e4 View commit details

Commits on Feb 26, 2025

  1. Copy the full SHA
    cc7d2c7 View commit details
  2. Fix merger of URI with authority component

    hsbt and nobu committed Feb 26, 2025
    Copy the full SHA
    75aeb4a View commit details
  3. Merge pull request #155 from ruby/remove-userinfo-v0-13

    Remove userinfo for v0.13.x
    hsbt authored Feb 26, 2025
    Copy the full SHA
    07fe169 View commit details
  4. Bump up v0.13.2

    hsbt committed Feb 26, 2025
    Copy the full SHA
    cef02d6 View commit details
Showing with 31 additions and 9 deletions.
  1. +3 −0 .github/workflows/test.yml
  2. +2 −0 lib/uri/common.rb
  3. +7 −8 lib/uri/generic.rb
  4. +1 −1 lib/uri/version.rb
  5. +18 −0 test/uri/test_generic.rb
3 changes: 3 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -15,6 +15,9 @@ jobs:
matrix:
ruby: ${{ fromJson(needs.ruby-versions.outputs.versions) }}
os: [ ubuntu-latest, macos-latest ]
exclude:
- ruby: 2.5
os: macos-latest
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
2 changes: 2 additions & 0 deletions lib/uri/common.rb
Original file line number Diff line number Diff line change
@@ -19,6 +19,8 @@ module URI
Parser = RFC2396_Parser
RFC3986_PARSER = RFC3986_Parser.new
Ractor.make_shareable(RFC3986_PARSER) if defined?(Ractor)
RFC2396_PARSER = RFC2396_Parser.new
Ractor.make_shareable(RFC2396_PARSER) if defined?(Ractor)

# URI::Parser.new
DEFAULT_PARSER = Parser.new
15 changes: 7 additions & 8 deletions lib/uri/generic.rb
Original file line number Diff line number Diff line change
@@ -1133,17 +1133,16 @@ def merge(oth)
base.fragment=(nil)

# RFC2396, Section 5.2, 4)
if !authority
base.set_path(merge_path(base.path, rel.path)) if base.path && rel.path
else
# RFC2396, Section 5.2, 4)
base.set_path(rel.path) if rel.path
if authority
base.set_userinfo(rel.userinfo)
base.set_host(rel.host)
base.set_port(rel.port || base.default_port)
base.set_path(rel.path)
elsif base.path && rel.path
base.set_path(merge_path(base.path, rel.path))
end

# RFC2396, Section 5.2, 7)
base.set_userinfo(rel.userinfo) if rel.userinfo
base.set_host(rel.host) if rel.host
base.set_port(rel.port) if rel.port
base.query = rel.query if rel.query
base.fragment=(rel.fragment) if rel.fragment

2 changes: 1 addition & 1 deletion lib/uri/version.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module URI
# :stopdoc:
VERSION_CODE = '001300'.freeze
VERSION_CODE = '001302'.freeze
VERSION = VERSION_CODE.scan(/../).collect{|n| n.to_i}.join('.').freeze
# :startdoc:
end
18 changes: 18 additions & 0 deletions test/uri/test_generic.rb
Original file line number Diff line number Diff line change
@@ -164,6 +164,17 @@ def test_parse
# must be empty string to identify as path-abempty, not path-absolute
assert_equal('', url.host)
assert_equal('http:////example.com', url.to_s)

# sec-2957667
url = URI.parse('http://user:pass@example.com').merge('//example.net')
assert_equal('http://example.net', url.to_s)
assert_nil(url.userinfo)
url = URI.join('http://user:pass@example.com', '//example.net')
assert_equal('http://example.net', url.to_s)
assert_nil(url.userinfo)
url = URI.parse('http://user:pass@example.com') + '//example.net'
assert_equal('http://example.net', url.to_s)
assert_nil(url.userinfo)
end

def test_parse_scheme_with_symbols
@@ -256,6 +267,13 @@ def test_merge
assert_equal(u0, u1)
end

def test_merge_authority
u = URI.parse('http://user:pass@example.com:8080')
u0 = URI.parse('http://new.example.org/path')
u1 = u.merge('//new.example.org/path')
assert_equal(u0, u1)
end

def test_route
url = URI.parse('http://hoge/a.html').route_to('http://hoge/b.html')
assert_equal('b.html', url.to_s)