uri 0.10.3 → 0.11.0

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of uri might be problematic. Click here for more details.

checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 402696d2448e1f1d9d14d6307ee4a61f4e5370760088c03baefcfc904bae529c
4
- data.tar.gz: 9d073ce507b29a3fe2eea321a53fd614da025f964442a8aa47f73f165996765c
3
+ metadata.gz: f7d8f9f16782c6d943477fcd62e6cc5799e7a08a9139fe301be0aa378805ea94
4
+ data.tar.gz: 24ce150ab74ba59971c8e5383a3901b1fc00decf672c89533cbece16283727af
5
5
  SHA512:
6
- metadata.gz: 3ef56ee95d5cd944c344db8c55e3023898cefc82b3382dc9fc5bf0a9f7bb959901c492f7829cc3ebed02f35ec978a680a3608839fa5fc4072708220fa4b818c9
7
- data.tar.gz: 6b2d67e0b317f800a1db9d2b0e64bc757abb7f53d5e006e7e440f1f04b562afbd5c2184ec2458ea5c76983866024d5fc56189e650f1b2187b7ac7907d4d892e4
6
+ metadata.gz: 376958fe2bd228dd4baff525452637cbb0af013cc93313f71c64821b75459f868a3c10ea11fdbe2093975de52669175866c1b4c9b38e594d756b1692d2976bc4
7
+ data.tar.gz: f57a16492c7ad239a29228e7dcb0f9cdb89b54a37c24e3a39677927fb3cf46f9899f1a2977f2542e1b5bd93adcbbeba8a0b7d0790c798a70dd7a07d2312034b7
@@ -1,4 +1,4 @@
1
- name: ubuntu
1
+ name: CI
2
2
 
3
3
  on: [push, pull_request]
4
4
 
@@ -7,18 +7,16 @@ jobs:
7
7
  name: build (${{ matrix.ruby }} / ${{ matrix.os }})
8
8
  strategy:
9
9
  matrix:
10
- ruby: [ 2.7, 2.6, 2.5, 2.4, head ]
10
+ ruby: [ '3.0', 2.7, 2.6, 2.5, 2.4, head ]
11
11
  os: [ ubuntu-latest, macos-latest ]
12
12
  runs-on: ${{ matrix.os }}
13
13
  steps:
14
- - uses: actions/checkout@master
14
+ - uses: actions/checkout@v2
15
15
  - name: Set up Ruby
16
16
  uses: ruby/setup-ruby@v1
17
17
  with:
18
18
  ruby-version: ${{ matrix.ruby }}
19
19
  - name: Install dependencies
20
- run: |
21
- gem install bundler --no-document
22
- bundle install
20
+ run: bundle install
23
21
  - name: Run test
24
22
  run: rake test
data/Gemfile CHANGED
@@ -6,5 +6,4 @@ group :development do
6
6
  gem "bundler"
7
7
  gem "rake"
8
8
  gem "test-unit"
9
- gem "test-unit-ruby-core"
10
9
  end
data/README.md CHANGED
@@ -1,7 +1,8 @@
1
1
  # URI
2
2
 
3
- URI is a module providing classes to handle Uniform Resource Identifiers
4
- (RFC2396[http://tools.ietf.org/html/rfc2396]).
3
+ [![CI](https://github.com/ruby/uri/actions/workflows/test.yml/badge.svg)](https://github.com/ruby/uri/actions/workflows/test.yml)
4
+
5
+ URI is a module providing classes to handle Uniform Resource Identifiers [RFC2396](http://tools.ietf.org/html/rfc2396).
5
6
 
6
7
  ## Features
7
8
 
data/lib/uri/common.rb CHANGED
@@ -16,6 +16,7 @@ module URI
16
16
  REGEXP = RFC2396_REGEXP
17
17
  Parser = RFC2396_Parser
18
18
  RFC3986_PARSER = RFC3986_Parser.new
19
+ Ractor.make_shareable(RFC3986_PARSER) if defined?(Ractor)
19
20
 
20
21
  # URI::Parser.new
21
22
  DEFAULT_PARSER = Parser.new
@@ -27,6 +28,7 @@ module URI
27
28
  DEFAULT_PARSER.regexp.each_pair do |sym, str|
28
29
  const_set(sym, str)
29
30
  end
31
+ Ractor.make_shareable(DEFAULT_PARSER) if defined?(Ractor)
30
32
 
31
33
  module Util # :nodoc:
32
34
  def make_components_hash(klass, array_hash)
@@ -62,22 +64,37 @@ module URI
62
64
 
63
65
  include REGEXP
64
66
 
65
- @@schemes = {}
67
+ module Schemes
68
+ end
69
+ private_constant :Schemes
70
+
71
+ def self.register_scheme(scheme, klass)
72
+ Schemes.const_set(scheme, klass)
73
+ end
74
+
66
75
  # Returns a Hash of the defined schemes.
67
76
  def self.scheme_list
68
- @@schemes
77
+ Schemes.constants.map { |name|
78
+ [name.to_s.upcase, Schemes.const_get(name)]
79
+ }.to_h
69
80
  end
70
81
 
82
+ INITIAL_SCHEMES = scheme_list
83
+ private_constant :INITIAL_SCHEMES
84
+ Ractor.make_shareable(INITIAL_SCHEMES) if defined?(Ractor)
85
+
71
86
  #
72
87
  # Construct a URI instance, using the scheme to detect the appropriate class
73
88
  # from +URI.scheme_list+.
74
89
  #
75
90
  def self.for(scheme, *arguments, default: Generic)
76
- if scheme
77
- uri_class = @@schemes[scheme.upcase] || default
78
- else
79
- uri_class = default
91
+ const_name = scheme.to_s.upcase
92
+
93
+ uri_class = INITIAL_SCHEMES[const_name]
94
+ uri_class ||= if /\A[A-Z]\w*\z/.match?(const_name) && Schemes.const_defined?(const_name, false)
95
+ Schemes.const_get(const_name, false)
80
96
  end
97
+ uri_class ||= default
81
98
 
82
99
  return uri_class.new(scheme, *arguments)
83
100
  end
@@ -321,7 +338,7 @@ module URI
321
338
  #
322
339
  # See URI.encode_www_form_component, URI.decode_www_form.
323
340
  def self.decode_www_form_component(str, enc=Encoding::UTF_8)
324
- raise ArgumentError, "invalid %-encoding (#{str})" if /%(?!\h\h)/ =~ str
341
+ raise ArgumentError, "invalid %-encoding (#{str})" if /%(?!\h\h)/.match?(str)
325
342
  str.b.gsub(/\+|%\h\h/, TBLDECWWWCOMP_).force_encoding(enc)
326
343
  end
327
344
 
@@ -653,6 +670,7 @@ module URI
653
670
  "utf-16"=>"utf-16le",
654
671
  "utf-16le"=>"utf-16le",
655
672
  } # :nodoc:
673
+ Ractor.make_shareable(WEB_ENCODINGS_) if defined?(Ractor)
656
674
 
657
675
  # :nodoc:
658
676
  # return encoding or nil
data/lib/uri/file.rb CHANGED
@@ -90,5 +90,5 @@ module URI
90
90
  end
91
91
  end
92
92
 
93
- @@schemes['FILE'] = File
93
+ register_scheme 'FILE', File
94
94
  end
data/lib/uri/ftp.rb CHANGED
@@ -262,5 +262,6 @@ module URI
262
262
  return str
263
263
  end
264
264
  end
265
- @@schemes['FTP'] = FTP
265
+
266
+ register_scheme 'FTP', FTP
266
267
  end
data/lib/uri/generic.rb CHANGED
@@ -643,7 +643,7 @@ module URI
643
643
  #
644
644
  def hostname
645
645
  v = self.host
646
- /\A\[(.*)\]\z/ =~ v ? $1 : v
646
+ v&.start_with?('[') && v.end_with?(']') ? v[1..-2] : v
647
647
  end
648
648
 
649
649
  # Sets the host part of the URI as the argument with brackets for IPv6 addresses.
@@ -659,7 +659,7 @@ module URI
659
659
  # it is wrapped with brackets.
660
660
  #
661
661
  def hostname=(v)
662
- v = "[#{v}]" if /\A\[.*\]\z/ !~ v && /:/ =~ v
662
+ v = "[#{v}]" if !(v&.start_with?('[') && v&.end_with?(']')) && v&.index(':')
663
663
  self.host = v
664
664
  end
665
665
 
@@ -1514,9 +1514,19 @@ module URI
1514
1514
  proxy_uri = env["CGI_#{name.upcase}"]
1515
1515
  end
1516
1516
  elsif name == 'http_proxy'
1517
- unless proxy_uri = env[name]
1518
- if proxy_uri = env[name.upcase]
1519
- warn 'The environment variable HTTP_PROXY is discouraged. Use http_proxy.', uplevel: 1
1517
+ if RUBY_ENGINE == 'jruby' && p_addr = ENV_JAVA['http.proxyHost']
1518
+ p_port = ENV_JAVA['http.proxyPort']
1519
+ if p_user = ENV_JAVA['http.proxyUser']
1520
+ p_pass = ENV_JAVA['http.proxyPass']
1521
+ proxy_uri = "http://#{p_user}:#{p_pass}@#{p_addr}:#{p_port}"
1522
+ else
1523
+ proxy_uri = "http://#{p_addr}:#{p_port}"
1524
+ end
1525
+ else
1526
+ unless proxy_uri = env[name]
1527
+ if proxy_uri = env[name.upcase]
1528
+ warn 'The environment variable HTTP_PROXY is discouraged. Use http_proxy.', uplevel: 1
1529
+ end
1520
1530
  end
1521
1531
  end
1522
1532
  else
data/lib/uri/http.rb CHANGED
@@ -80,8 +80,46 @@ module URI
80
80
  url = @query ? "#@path?#@query" : @path.dup
81
81
  url.start_with?(?/.freeze) ? url : ?/ + url
82
82
  end
83
- end
84
83
 
85
- @@schemes['HTTP'] = HTTP
84
+ #
85
+ # == Description
86
+ #
87
+ # Returns the authority for an HTTP uri, as defined in
88
+ # https://datatracker.ietf.org/doc/html/rfc3986/#section-3.2.
89
+ #
90
+ #
91
+ # Example:
92
+ #
93
+ # URI::HTTP.build(host: 'www.example.com', path: '/foo/bar').authority #=> "www.example.com"
94
+ # URI::HTTP.build(host: 'www.example.com', port: 8000, path: '/foo/bar').authority #=> "www.example.com:8000"
95
+ # URI::HTTP.build(host: 'www.example.com', port: 80, path: '/foo/bar').authority #=> "www.example.com"
96
+ #
97
+ def authority
98
+ if port == default_port
99
+ host
100
+ else
101
+ "#{host}:#{port}"
102
+ end
103
+ end
104
+
105
+ #
106
+ # == Description
107
+ #
108
+ # Returns the origin for an HTTP uri, as defined in
109
+ # https://datatracker.ietf.org/doc/html/rfc6454.
110
+ #
111
+ #
112
+ # Example:
113
+ #
114
+ # URI::HTTP.build(host: 'www.example.com', path: '/foo/bar').origin #=> "http://www.example.com"
115
+ # URI::HTTP.build(host: 'www.example.com', port: 8000, path: '/foo/bar').origin #=> "http://www.example.com:8000"
116
+ # URI::HTTP.build(host: 'www.example.com', port: 80, path: '/foo/bar').origin #=> "http://www.example.com"
117
+ # URI::HTTPS.build(host: 'www.example.com', path: '/foo/bar').origin #=> "https://www.example.com"
118
+ #
119
+ def origin
120
+ "#{scheme}://#{authority}"
121
+ end
122
+ end
86
123
 
124
+ register_scheme 'HTTP', HTTP
87
125
  end
data/lib/uri/https.rb CHANGED
@@ -18,5 +18,6 @@ module URI
18
18
  # A Default port of 443 for URI::HTTPS
19
19
  DEFAULT_PORT = 443
20
20
  end
21
- @@schemes['HTTPS'] = HTTPS
21
+
22
+ register_scheme 'HTTPS', HTTPS
22
23
  end
data/lib/uri/ldap.rb CHANGED
@@ -257,5 +257,5 @@ module URI
257
257
  end
258
258
  end
259
259
 
260
- @@schemes['LDAP'] = LDAP
260
+ register_scheme 'LDAP', LDAP
261
261
  end
data/lib/uri/ldaps.rb CHANGED
@@ -17,5 +17,6 @@ module URI
17
17
  # A Default port of 636 for URI::LDAPS
18
18
  DEFAULT_PORT = 636
19
19
  end
20
- @@schemes['LDAPS'] = LDAPS
20
+
21
+ register_scheme 'LDAPS', LDAPS
21
22
  end
data/lib/uri/mailto.rb CHANGED
@@ -289,5 +289,5 @@ module URI
289
289
  alias to_rfc822text to_mailtext
290
290
  end
291
291
 
292
- @@schemes['MAILTO'] = MailTo
292
+ register_scheme 'MAILTO', MailTo
293
293
  end
@@ -116,7 +116,7 @@ module URI
116
116
  # See also URI::Parser.initialize_regexp.
117
117
  attr_reader :regexp
118
118
 
119
- # Returns a split URI against regexp[:ABS_URI].
119
+ # Returns a split URI against +regexp[:ABS_URI]+.
120
120
  def split(uri)
121
121
  case uri
122
122
  when ''
@@ -257,8 +257,8 @@ module URI
257
257
  end
258
258
  end
259
259
 
260
- # Returns Regexp that is default self.regexp[:ABS_URI_REF],
261
- # unless +schemes+ is provided. Then it is a Regexp.union with self.pattern[:X_ABS_URI].
260
+ # Returns Regexp that is default +self.regexp[:ABS_URI_REF]+,
261
+ # unless +schemes+ is provided. Then it is a Regexp.union with +self.pattern[:X_ABS_URI]+.
262
262
  def make_regexp(schemes = nil)
263
263
  unless schemes
264
264
  @regexp[:ABS_URI_REF]
@@ -277,7 +277,7 @@ module URI
277
277
  # +str+::
278
278
  # String to make safe
279
279
  # +unsafe+::
280
- # Regexp to apply. Defaults to self.regexp[:UNSAFE]
280
+ # Regexp to apply. Defaults to +self.regexp[:UNSAFE]+
281
281
  #
282
282
  # == Description
283
283
  #
@@ -309,7 +309,7 @@ module URI
309
309
  # +str+::
310
310
  # String to remove escapes from
311
311
  # +escaped+::
312
- # Regexp to apply. Defaults to self.regexp[:ESCAPED]
312
+ # Regexp to apply. Defaults to +self.regexp[:ESCAPED]+
313
313
  #
314
314
  # == Description
315
315
  #
@@ -322,8 +322,14 @@ module URI
322
322
  end
323
323
 
324
324
  @@to_s = Kernel.instance_method(:to_s)
325
- def inspect
326
- @@to_s.bind_call(self)
325
+ if @@to_s.respond_to?(:bind_call)
326
+ def inspect
327
+ @@to_s.bind_call(self)
328
+ end
329
+ else
330
+ def inspect
331
+ @@to_s.bind(self).call
332
+ end
327
333
  end
328
334
 
329
335
  private
@@ -491,8 +497,8 @@ module URI
491
497
  ret = {}
492
498
 
493
499
  # for URI::split
494
- ret[:ABS_URI] = Regexp.new('\A\s*+' + pattern[:X_ABS_URI] + '\s*\z', Regexp::EXTENDED)
495
- ret[:REL_URI] = Regexp.new('\A\s*+' + pattern[:X_REL_URI] + '\s*\z', Regexp::EXTENDED)
500
+ ret[:ABS_URI] = Regexp.new('\A\s*' + pattern[:X_ABS_URI] + '\s*\z', Regexp::EXTENDED)
501
+ ret[:REL_URI] = Regexp.new('\A\s*' + pattern[:X_REL_URI] + '\s*\z', Regexp::EXTENDED)
496
502
 
497
503
  # for URI::extract
498
504
  ret[:URI_REF] = Regexp.new(pattern[:URI_REF])
@@ -3,8 +3,8 @@ module URI
3
3
  class RFC3986_Parser # :nodoc:
4
4
  # URI defined in RFC3986
5
5
  # this regexp is modified not to host is not empty string
6
- RFC3986_URI = /\A(?<URI>(?<scheme>[A-Za-z][+\-.0-9A-Za-z]*+):(?<hier-part>\/\/(?<authority>(?:(?<userinfo>(?:%\h\h|[!$&-.0-;=A-Z_a-z~])*+)@)?(?<host>(?<IP-literal>\[(?:(?<IPv6address>(?:\h{1,4}:){6}(?<ls32>\h{1,4}:\h{1,4}|(?<IPv4address>(?<dec-octet>[1-9]\d|1\d{2}|2[0-4]\d|25[0-5]|\d)\.\g<dec-octet>\.\g<dec-octet>\.\g<dec-octet>))|::(?:\h{1,4}:){5}\g<ls32>|\h{1,4}?::(?:\h{1,4}:){4}\g<ls32>|(?:(?:\h{1,4}:)?\h{1,4})?::(?:\h{1,4}:){3}\g<ls32>|(?:(?:\h{1,4}:){,2}\h{1,4})?::(?:\h{1,4}:){2}\g<ls32>|(?:(?:\h{1,4}:){,3}\h{1,4})?::\h{1,4}:\g<ls32>|(?:(?:\h{1,4}:){,4}\h{1,4})?::\g<ls32>|(?:(?:\h{1,4}:){,5}\h{1,4})?::\h{1,4}|(?:(?:\h{1,4}:){,6}\h{1,4})?::)|(?<IPvFuture>v\h++\.[!$&-.0-;=A-Z_a-z~]++))\])|\g<IPv4address>|(?<reg-name>(?:%\h\h|[!$&-.0-9;=A-Z_a-z~])++))?(?::(?<port>\d*+))?)(?<path-abempty>(?:\/(?<segment>(?:%\h\h|[!$&-.0-;=@-Z_a-z~])*+))*+)|(?<path-absolute>\/(?:(?<segment-nz>(?:%\h\h|[!$&-.0-;=@-Z_a-z~])++)(?:\/\g<segment>)*+)?)|(?<path-rootless>\g<segment-nz>(?:\/\g<segment>)*+)|(?<path-empty>))(?:\?(?<query>[^#]*+))?(?:\#(?<fragment>(?:%\h\h|[!$&-.0-;=@-Z_a-z~\/?])*+))?)\z/
7
- RFC3986_relative_ref = /\A(?<relative-ref>(?<relative-part>\/\/(?<authority>(?:(?<userinfo>(?:%\h\h|[!$&-.0-;=A-Z_a-z~])*+)@)?(?<host>(?<IP-literal>\[(?:(?<IPv6address>(?:\h{1,4}:){6}(?<ls32>\h{1,4}:\h{1,4}|(?<IPv4address>(?<dec-octet>[1-9]\d|1\d{2}|2[0-4]\d|25[0-5]|\d)\.\g<dec-octet>\.\g<dec-octet>\.\g<dec-octet>))|::(?:\h{1,4}:){5}\g<ls32>|\h{1,4}?::(?:\h{1,4}:){4}\g<ls32>|(?:(?:\h{1,4}:){,1}\h{1,4})?::(?:\h{1,4}:){3}\g<ls32>|(?:(?:\h{1,4}:){,2}\h{1,4})?::(?:\h{1,4}:){2}\g<ls32>|(?:(?:\h{1,4}:){,3}\h{1,4})?::\h{1,4}:\g<ls32>|(?:(?:\h{1,4}:){,4}\h{1,4})?::\g<ls32>|(?:(?:\h{1,4}:){,5}\h{1,4})?::\h{1,4}|(?:(?:\h{1,4}:){,6}\h{1,4})?::)|(?<IPvFuture>v\h++\.[!$&-.0-;=A-Z_a-z~]++))\])|\g<IPv4address>|(?<reg-name>(?:%\h\h|[!$&-.0-9;=A-Z_a-z~])++))?(?::(?<port>\d*+))?)(?<path-abempty>(?:\/(?<segment>(?:%\h\h|[!$&-.0-;=@-Z_a-z~])*+))*+)|(?<path-absolute>\/(?:(?<segment-nz>(?:%\h\h|[!$&-.0-;=@-Z_a-z~])++)(?:\/\g<segment>)*+)?)|(?<path-noscheme>(?<segment-nz-nc>(?:%\h\h|[!$&-.0-9;=@-Z_a-z~])++)(?:\/\g<segment>)*+)|(?<path-empty>))(?:\?(?<query>[^#]*+))?(?:\#(?<fragment>(?:%\h\h|[!$&-.0-;=@-Z_a-z~\/?])*+))?)\z/
6
+ RFC3986_URI = /\A(?<URI>(?<scheme>[A-Za-z][+\-.0-9A-Za-z]*):(?<hier-part>\/\/(?<authority>(?:(?<userinfo>(?:%\h\h|[!$&-.0-;=A-Z_a-z~])*)@)?(?<host>(?<IP-literal>\[(?:(?<IPv6address>(?:\h{1,4}:){6}(?<ls32>\h{1,4}:\h{1,4}|(?<IPv4address>(?<dec-octet>[1-9]\d|1\d{2}|2[0-4]\d|25[0-5]|\d)\.\g<dec-octet>\.\g<dec-octet>\.\g<dec-octet>))|::(?:\h{1,4}:){5}\g<ls32>|\h{1,4}?::(?:\h{1,4}:){4}\g<ls32>|(?:(?:\h{1,4}:)?\h{1,4})?::(?:\h{1,4}:){3}\g<ls32>|(?:(?:\h{1,4}:){,2}\h{1,4})?::(?:\h{1,4}:){2}\g<ls32>|(?:(?:\h{1,4}:){,3}\h{1,4})?::\h{1,4}:\g<ls32>|(?:(?:\h{1,4}:){,4}\h{1,4})?::\g<ls32>|(?:(?:\h{1,4}:){,5}\h{1,4})?::\h{1,4}|(?:(?:\h{1,4}:){,6}\h{1,4})?::)|(?<IPvFuture>v\h+\.[!$&-.0-;=A-Z_a-z~]+))\])|\g<IPv4address>|(?<reg-name>(?:%\h\h|[!$&-.0-9;=A-Z_a-z~])+))?(?::(?<port>\d*))?)(?<path-abempty>(?:\/(?<segment>(?:%\h\h|[!$&-.0-;=@-Z_a-z~])*))*)|(?<path-absolute>\/(?:(?<segment-nz>(?:%\h\h|[!$&-.0-;=@-Z_a-z~])+)(?:\/\g<segment>)*)?)|(?<path-rootless>\g<segment-nz>(?:\/\g<segment>)*)|(?<path-empty>))(?:\?(?<query>[^#]*))?(?:\#(?<fragment>(?:%\h\h|[!$&-.0-;=@-Z_a-z~\/?])*))?)\z/
7
+ RFC3986_relative_ref = /\A(?<relative-ref>(?<relative-part>\/\/(?<authority>(?:(?<userinfo>(?:%\h\h|[!$&-.0-;=A-Z_a-z~])*)@)?(?<host>(?<IP-literal>\[(?<IPv6address>(?:\h{1,4}:){6}(?<ls32>\h{1,4}:\h{1,4}|(?<IPv4address>(?<dec-octet>[1-9]\d|1\d{2}|2[0-4]\d|25[0-5]|\d)\.\g<dec-octet>\.\g<dec-octet>\.\g<dec-octet>))|::(?:\h{1,4}:){5}\g<ls32>|\h{1,4}?::(?:\h{1,4}:){4}\g<ls32>|(?:(?:\h{1,4}:){,1}\h{1,4})?::(?:\h{1,4}:){3}\g<ls32>|(?:(?:\h{1,4}:){,2}\h{1,4})?::(?:\h{1,4}:){2}\g<ls32>|(?:(?:\h{1,4}:){,3}\h{1,4})?::\h{1,4}:\g<ls32>|(?:(?:\h{1,4}:){,4}\h{1,4})?::\g<ls32>|(?:(?:\h{1,4}:){,5}\h{1,4})?::\h{1,4}|(?:(?:\h{1,4}:){,6}\h{1,4})?::)|(?<IPvFuture>v\h+\.[!$&-.0-;=A-Z_a-z~]+)\])|\g<IPv4address>|(?<reg-name>(?:%\h\h|[!$&-.0-9;=A-Z_a-z~])+))?(?::(?<port>\d*))?)(?<path-abempty>(?:\/(?<segment>(?:%\h\h|[!$&-.0-;=@-Z_a-z~])*))*)|(?<path-absolute>\/(?:(?<segment-nz>(?:%\h\h|[!$&-.0-;=@-Z_a-z~])+)(?:\/\g<segment>)*)?)|(?<path-noscheme>(?<segment-nz-nc>(?:%\h\h|[!$&-.0-9;=@-Z_a-z~])+)(?:\/\g<segment>)*)|(?<path-empty>))(?:\?(?<query>[^#]*))?(?:\#(?<fragment>(?:%\h\h|[!$&-.0-;=@-Z_a-z~\/?])*))?)\z/
8
8
  attr_reader :regexp
9
9
 
10
10
  def initialize
@@ -79,8 +79,14 @@ module URI
79
79
  end
80
80
 
81
81
  @@to_s = Kernel.instance_method(:to_s)
82
- def inspect
83
- @@to_s.bind_call(self)
82
+ if @@to_s.respond_to?(:bind_call)
83
+ def inspect
84
+ @@to_s.bind_call(self)
85
+ end
86
+ else
87
+ def inspect
88
+ @@to_s.bind(self).call
89
+ end
84
90
  end
85
91
 
86
92
  private
@@ -95,7 +101,7 @@ module URI
95
101
  QUERY: /\A(?:%\h\h|[!$&-.0-;=@-Z_a-z~\/?])*\z/,
96
102
  FRAGMENT: /\A(?:%\h\h|[!$&-.0-;=@-Z_a-z~\/?])*\z/,
97
103
  OPAQUE: /\A(?:[^\/].*)?\z/,
98
- PORT: /\A[\x09\x0a\x0c\x0d ]*+\d*[\x09\x0a\x0c\x0d ]*\z/,
104
+ PORT: /\A[\x09\x0a\x0c\x0d ]*\d*[\x09\x0a\x0c\x0d ]*\z/,
99
105
  }
100
106
  end
101
107
 
data/lib/uri/version.rb CHANGED
@@ -1,6 +1,6 @@
1
1
  module URI
2
2
  # :stopdoc:
3
- VERSION_CODE = '001003'.freeze
3
+ VERSION_CODE = '001100'.freeze
4
4
  VERSION = VERSION_CODE.scan(/../).collect{|n| n.to_i}.join('.').freeze
5
5
  # :startdoc:
6
6
  end
data/lib/uri/ws.rb CHANGED
@@ -79,6 +79,5 @@ module URI
79
79
  end
80
80
  end
81
81
 
82
- @@schemes['WS'] = WS
83
-
82
+ register_scheme 'WS', WS
84
83
  end
data/lib/uri/wss.rb CHANGED
@@ -18,5 +18,6 @@ module URI
18
18
  # A Default port of 443 for URI::WSS
19
19
  DEFAULT_PORT = 443
20
20
  end
21
- @@schemes['WSS'] = WSS
21
+
22
+ register_scheme 'WSS', WSS
22
23
  end
data/lib/uri.rb CHANGED
@@ -30,7 +30,7 @@
30
30
  # class RSYNC < Generic
31
31
  # DEFAULT_PORT = 873
32
32
  # end
33
- # @@schemes['RSYNC'] = RSYNC
33
+ # register_scheme 'RSYNC', RSYNC
34
34
  # end
35
35
  # #=> URI::RSYNC
36
36
  #
@@ -70,7 +70,6 @@
70
70
  # - URI::REGEXP - (in uri/common.rb)
71
71
  # - URI::REGEXP::PATTERN - (in uri/common.rb)
72
72
  # - URI::Util - (in uri/common.rb)
73
- # - URI::Escape - (in uri/common.rb)
74
73
  # - URI::Error - (in uri/common.rb)
75
74
  # - URI::InvalidURIError - (in uri/common.rb)
76
75
  # - URI::InvalidComponentError - (in uri/common.rb)
@@ -101,3 +100,4 @@ require_relative 'uri/https'
101
100
  require_relative 'uri/ldap'
102
101
  require_relative 'uri/ldaps'
103
102
  require_relative 'uri/mailto'
103
+ require_relative 'uri/ws'
data/uri.gemspec CHANGED
@@ -15,6 +15,8 @@ Gem::Specification.new do |spec|
15
15
  spec.homepage = "https://github.com/ruby/uri"
16
16
  spec.licenses = ["Ruby", "BSD-2-Clause"]
17
17
 
18
+ spec.required_ruby_version = '>= 2.4'
19
+
18
20
  spec.metadata["homepage_uri"] = spec.homepage
19
21
  spec.metadata["source_code_uri"] = spec.homepage
20
22
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: uri
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.10.3
4
+ version: 0.11.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Akira Yamada
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2023-06-29 00:00:00.000000000 Z
11
+ date: 2021-10-21 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: URI is a module providing classes to handle Uniform Resource Identifiers
14
14
  email:
@@ -56,14 +56,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
56
56
  requirements:
57
57
  - - ">="
58
58
  - !ruby/object:Gem::Version
59
- version: '0'
59
+ version: '2.4'
60
60
  required_rubygems_version: !ruby/object:Gem::Requirement
61
61
  requirements:
62
62
  - - ">="
63
63
  - !ruby/object:Gem::Version
64
64
  version: '0'
65
65
  requirements: []
66
- rubygems_version: 3.3.26
66
+ rubygems_version: 3.3.0.dev
67
67
  signing_key:
68
68
  specification_version: 4
69
69
  summary: URI is a module providing classes to handle Uniform Resource Identifiers