uri 0.10.3 → 0.13.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/lib/uri/generic.rb CHANGED
@@ -186,18 +186,18 @@ module URI
186
186
 
187
187
  if arg_check
188
188
  self.scheme = scheme
189
- self.userinfo = userinfo
190
189
  self.hostname = host
191
190
  self.port = port
191
+ self.userinfo = userinfo
192
192
  self.path = path
193
193
  self.query = query
194
194
  self.opaque = opaque
195
195
  self.fragment = fragment
196
196
  else
197
197
  self.set_scheme(scheme)
198
- self.set_userinfo(userinfo)
199
198
  self.set_host(host)
200
199
  self.set_port(port)
200
+ self.set_userinfo(userinfo)
201
201
  self.set_path(path)
202
202
  self.query = query
203
203
  self.set_opaque(opaque)
@@ -511,7 +511,7 @@ module URI
511
511
  user, password = split_userinfo(user)
512
512
  end
513
513
  @user = user
514
- @password = password if password
514
+ @password = password
515
515
 
516
516
  [@user, @password]
517
517
  end
@@ -522,7 +522,7 @@ module URI
522
522
  # See also URI::Generic.user=.
523
523
  #
524
524
  def set_user(v)
525
- set_userinfo(v, @password)
525
+ set_userinfo(v, nil)
526
526
  v
527
527
  end
528
528
  protected :set_user
@@ -564,16 +564,32 @@ module URI
564
564
  end
565
565
  end
566
566
 
567
- # Returns the user component.
567
+ # Returns the user component (without URI decoding).
568
568
  def user
569
569
  @user
570
570
  end
571
571
 
572
- # Returns the password component.
572
+ # Returns the password component (without URI decoding).
573
573
  def password
574
574
  @password
575
575
  end
576
576
 
577
+ # Returns the authority info (array of user, password, host and
578
+ # port), if any is set. Or returns +nil+.
579
+ def authority
580
+ return @user, @password, @host, @port if @user || @password || @host || @port
581
+ end
582
+
583
+ # Returns the user component after URI decoding.
584
+ def decoded_user
585
+ URI.decode_uri_component(@user) if @user
586
+ end
587
+
588
+ # Returns the password component after URI decoding.
589
+ def decoded_password
590
+ URI.decode_uri_component(@password) if @password
591
+ end
592
+
577
593
  #
578
594
  # Checks the host +v+ component for RFC2396 compliance
579
595
  # and against the URI::Parser Regexp for :HOST.
@@ -605,6 +621,13 @@ module URI
605
621
  end
606
622
  protected :set_host
607
623
 
624
+ # Protected setter for the authority info (+user+, +password+, +host+
625
+ # and +port+). If +port+ is +nil+, +default_port+ will be set.
626
+ #
627
+ protected def set_authority(user, password, host, port = nil)
628
+ @user, @password, @host, @port = user, password, host, port || self.default_port
629
+ end
630
+
608
631
  #
609
632
  # == Args
610
633
  #
@@ -629,6 +652,7 @@ module URI
629
652
  def host=(v)
630
653
  check_host(v)
631
654
  set_host(v)
655
+ set_userinfo(nil)
632
656
  v
633
657
  end
634
658
 
@@ -643,7 +667,7 @@ module URI
643
667
  #
644
668
  def hostname
645
669
  v = self.host
646
- /\A\[(.*)\]\z/ =~ v ? $1 : v
670
+ v&.start_with?('[') && v.end_with?(']') ? v[1..-2] : v
647
671
  end
648
672
 
649
673
  # Sets the host part of the URI as the argument with brackets for IPv6 addresses.
@@ -659,7 +683,7 @@ module URI
659
683
  # it is wrapped with brackets.
660
684
  #
661
685
  def hostname=(v)
662
- v = "[#{v}]" if /\A\[.*\]\z/ !~ v && /:/ =~ v
686
+ v = "[#{v}]" if !(v&.start_with?('[') && v&.end_with?(']')) && v&.index(':')
663
687
  self.host = v
664
688
  end
665
689
 
@@ -719,6 +743,7 @@ module URI
719
743
  def port=(v)
720
744
  check_port(v)
721
745
  set_port(v)
746
+ set_userinfo(nil)
722
747
  port
723
748
  end
724
749
 
@@ -1111,7 +1136,7 @@ module URI
1111
1136
 
1112
1137
  base = self.dup
1113
1138
 
1114
- authority = rel.userinfo || rel.host || rel.port
1139
+ authority = rel.authority
1115
1140
 
1116
1141
  # RFC2396, Section 5.2, 2)
1117
1142
  if (rel.path.nil? || rel.path.empty?) && !authority && !rel.query
@@ -1123,17 +1148,14 @@ module URI
1123
1148
  base.fragment=(nil)
1124
1149
 
1125
1150
  # RFC2396, Section 5.2, 4)
1126
- if !authority
1127
- base.set_path(merge_path(base.path, rel.path)) if base.path && rel.path
1128
- else
1129
- # RFC2396, Section 5.2, 4)
1130
- base.set_path(rel.path) if rel.path
1151
+ if authority
1152
+ base.set_authority(*authority)
1153
+ base.set_path(rel.path)
1154
+ elsif base.path && rel.path
1155
+ base.set_path(merge_path(base.path, rel.path))
1131
1156
  end
1132
1157
 
1133
1158
  # RFC2396, Section 5.2, 7)
1134
- base.set_userinfo(rel.userinfo) if rel.userinfo
1135
- base.set_host(rel.host) if rel.host
1136
- base.set_port(rel.port) if rel.port
1137
1159
  base.query = rel.query if rel.query
1138
1160
  base.fragment=(rel.fragment) if rel.fragment
1139
1161
 
@@ -1366,6 +1388,7 @@ module URI
1366
1388
  end
1367
1389
  str
1368
1390
  end
1391
+ alias to_str to_s
1369
1392
 
1370
1393
  #
1371
1394
  # Compares two URIs.
@@ -1514,9 +1537,19 @@ module URI
1514
1537
  proxy_uri = env["CGI_#{name.upcase}"]
1515
1538
  end
1516
1539
  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
1540
+ if RUBY_ENGINE == 'jruby' && p_addr = ENV_JAVA['http.proxyHost']
1541
+ p_port = ENV_JAVA['http.proxyPort']
1542
+ if p_user = ENV_JAVA['http.proxyUser']
1543
+ p_pass = ENV_JAVA['http.proxyPass']
1544
+ proxy_uri = "http://#{p_user}:#{p_pass}@#{p_addr}:#{p_port}"
1545
+ else
1546
+ proxy_uri = "http://#{p_addr}:#{p_port}"
1547
+ end
1548
+ else
1549
+ unless proxy_uri = env[name]
1550
+ if proxy_uri = env[name.upcase]
1551
+ warn 'The environment variable HTTP_PROXY is discouraged. Use http_proxy.', uplevel: 1
1552
+ end
1520
1553
  end
1521
1554
  end
1522
1555
  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
@@ -15,7 +15,7 @@ module URI
15
15
  # RFC6068, the mailto URL scheme.
16
16
  #
17
17
  class MailTo < Generic
18
- include REGEXP
18
+ include RFC2396_REGEXP
19
19
 
20
20
  # A Default port of nil for URI::MailTo.
21
21
  DEFAULT_PORT = nil
@@ -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
@@ -1,10 +1,73 @@
1
- # frozen_string_literal: false
1
+ # frozen_string_literal: true
2
2
  module URI
3
3
  class RFC3986_Parser # :nodoc:
4
4
  # URI defined in RFC3986
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/
5
+ HOST = %r[
6
+ (?<IP-literal>\[(?:
7
+ (?<IPv6address>
8
+ (?:\h{1,4}:){6}
9
+ (?<ls32>\h{1,4}:\h{1,4}
10
+ | (?<IPv4address>(?<dec-octet>[1-9]\d|1\d{2}|2[0-4]\d|25[0-5]|\d)
11
+ \.\g<dec-octet>\.\g<dec-octet>\.\g<dec-octet>)
12
+ )
13
+ | ::(?:\h{1,4}:){5}\g<ls32>
14
+ | \h{1,4}?::(?:\h{1,4}:){4}\g<ls32>
15
+ | (?:(?:\h{1,4}:)?\h{1,4})?::(?:\h{1,4}:){3}\g<ls32>
16
+ | (?:(?:\h{1,4}:){,2}\h{1,4})?::(?:\h{1,4}:){2}\g<ls32>
17
+ | (?:(?:\h{1,4}:){,3}\h{1,4})?::\h{1,4}:\g<ls32>
18
+ | (?:(?:\h{1,4}:){,4}\h{1,4})?::\g<ls32>
19
+ | (?:(?:\h{1,4}:){,5}\h{1,4})?::\h{1,4}
20
+ | (?:(?:\h{1,4}:){,6}\h{1,4})?::
21
+ )
22
+ | (?<IPvFuture>v\h++\.[!$&-.0-9:;=A-Z_a-z~]++)
23
+ )\])
24
+ | \g<IPv4address>
25
+ | (?<reg-name>(?:%\h\h|[!$&-.0-9;=A-Z_a-z~])*+)
26
+ ]x
27
+
28
+ USERINFO = /(?:%\h\h|[!$&-.0-9:;=A-Z_a-z~])*+/
29
+
30
+ SCHEME = %r[[A-Za-z][+\-.0-9A-Za-z]*+].source
31
+ SEG = %r[(?:%\h\h|[!$&-.0-9:;=@A-Z_a-z~/])].source
32
+ SEG_NC = %r[(?:%\h\h|[!$&-.0-9;=@A-Z_a-z~])].source
33
+ FRAGMENT = %r[(?:%\h\h|[!$&-.0-9:;=@A-Z_a-z~/?])*+].source
34
+
35
+ RFC3986_URI = %r[\A
36
+ (?<seg>#{SEG}){0}
37
+ (?<URI>
38
+ (?<scheme>#{SCHEME}):
39
+ (?<hier-part>//
40
+ (?<authority>
41
+ (?:(?<userinfo>#{USERINFO.source})@)?
42
+ (?<host>#{HOST.source.delete(" \n")})
43
+ (?::(?<port>\d*+))?
44
+ )
45
+ (?<path-abempty>(?:/\g<seg>*+)?)
46
+ | (?<path-absolute>/((?!/)\g<seg>++)?)
47
+ | (?<path-rootless>(?!/)\g<seg>++)
48
+ | (?<path-empty>)
49
+ )
50
+ (?:\?(?<query>[^\#]*+))?
51
+ (?:\#(?<fragment>#{FRAGMENT}))?
52
+ )\z]x
53
+
54
+ RFC3986_relative_ref = %r[\A
55
+ (?<seg>#{SEG}){0}
56
+ (?<relative-ref>
57
+ (?<relative-part>//
58
+ (?<authority>
59
+ (?:(?<userinfo>#{USERINFO.source})@)?
60
+ (?<host>#{HOST.source.delete(" \n")}(?<!/))?
61
+ (?::(?<port>\d*+))?
62
+ )
63
+ (?<path-abempty>(?:/\g<seg>*+)?)
64
+ | (?<path-absolute>/\g<seg>*+)
65
+ | (?<path-noscheme>#{SEG_NC}++(?:/\g<seg>*+)?)
66
+ | (?<path-empty>)
67
+ )
68
+ (?:\?(?<query>[^#]*+))?
69
+ (?:\#(?<fragment>#{FRAGMENT}))?
70
+ )\z]x
8
71
  attr_reader :regexp
9
72
 
10
73
  def initialize
@@ -20,9 +83,9 @@ module URI
20
83
  uri.ascii_only? or
21
84
  raise InvalidURIError, "URI must be ascii only #{uri.dump}"
22
85
  if m = RFC3986_URI.match(uri)
23
- query = m["query".freeze]
24
- scheme = m["scheme".freeze]
25
- opaque = m["path-rootless".freeze]
86
+ query = m["query"]
87
+ scheme = m["scheme"]
88
+ opaque = m["path-rootless"]
26
89
  if opaque
27
90
  opaque << "?#{query}" if query
28
91
  [ scheme,
@@ -33,35 +96,35 @@ module URI
33
96
  nil, # path
34
97
  opaque,
35
98
  nil, # query
36
- m["fragment".freeze]
99
+ m["fragment"]
37
100
  ]
38
101
  else # normal
39
102
  [ scheme,
40
- m["userinfo".freeze],
41
- m["host".freeze],
42
- m["port".freeze],
103
+ m["userinfo"],
104
+ m["host"],
105
+ m["port"],
43
106
  nil, # registry
44
- (m["path-abempty".freeze] ||
45
- m["path-absolute".freeze] ||
46
- m["path-empty".freeze]),
107
+ (m["path-abempty"] ||
108
+ m["path-absolute"] ||
109
+ m["path-empty"]),
47
110
  nil, # opaque
48
111
  query,
49
- m["fragment".freeze]
112
+ m["fragment"]
50
113
  ]
51
114
  end
52
115
  elsif m = RFC3986_relative_ref.match(uri)
53
116
  [ nil, # scheme
54
- m["userinfo".freeze],
55
- m["host".freeze],
56
- m["port".freeze],
117
+ m["userinfo"],
118
+ m["host"],
119
+ m["port"],
57
120
  nil, # registry,
58
- (m["path-abempty".freeze] ||
59
- m["path-absolute".freeze] ||
60
- m["path-noscheme".freeze] ||
61
- m["path-empty".freeze]),
121
+ (m["path-abempty"] ||
122
+ m["path-absolute"] ||
123
+ m["path-noscheme"] ||
124
+ m["path-empty"]),
62
125
  nil, # opaque
63
- m["query".freeze],
64
- m["fragment".freeze]
126
+ m["query"],
127
+ m["fragment"]
65
128
  ]
66
129
  else
67
130
  raise InvalidURIError, "bad URI(is not URI?): #{uri.inspect}"
@@ -79,22 +142,28 @@ module URI
79
142
  end
80
143
 
81
144
  @@to_s = Kernel.instance_method(:to_s)
82
- def inspect
83
- @@to_s.bind_call(self)
145
+ if @@to_s.respond_to?(:bind_call)
146
+ def inspect
147
+ @@to_s.bind_call(self)
148
+ end
149
+ else
150
+ def inspect
151
+ @@to_s.bind(self).call
152
+ end
84
153
  end
85
154
 
86
155
  private
87
156
 
88
157
  def default_regexp # :nodoc:
89
158
  {
90
- SCHEME: /\A[A-Za-z][A-Za-z0-9+\-.]*\z/,
91
- USERINFO: /\A(?:%\h\h|[!$&-.0-;=A-Z_a-z~])*\z/,
92
- HOST: /\A(?:(?<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{,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~])*))\z/,
93
- ABS_PATH: /\A\/(?:%\h\h|[!$&-.0-;=@-Z_a-z~])*(?:\/(?:%\h\h|[!$&-.0-;=@-Z_a-z~])*)*\z/,
94
- REL_PATH: /\A(?:%\h\h|[!$&-.0-;=@-Z_a-z~])+(?:\/(?:%\h\h|[!$&-.0-;=@-Z_a-z~])*)*\z/,
95
- QUERY: /\A(?:%\h\h|[!$&-.0-;=@-Z_a-z~\/?])*\z/,
96
- FRAGMENT: /\A(?:%\h\h|[!$&-.0-;=@-Z_a-z~\/?])*\z/,
97
- OPAQUE: /\A(?:[^\/].*)?\z/,
159
+ SCHEME: %r[\A#{SCHEME}\z]o,
160
+ USERINFO: %r[\A#{USERINFO}\z]o,
161
+ HOST: %r[\A#{HOST}\z]o,
162
+ ABS_PATH: %r[\A/#{SEG}*+\z]o,
163
+ REL_PATH: %r[\A(?!/)#{SEG}++\z]o,
164
+ QUERY: %r[\A(?:%\h\h|[!$&-.0-9:;=@A-Z_a-z~/?])*+\z],
165
+ FRAGMENT: %r[\A#{FRAGMENT}\z]o,
166
+ OPAQUE: %r[\A(?:[^/].*)?\z],
98
167
  PORT: /\A[\x09\x0a\x0c\x0d ]*+\d*[\x09\x0a\x0c\x0d ]*\z/,
99
168
  }
100
169
  end
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 = '001303'.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,5 @@ 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'
104
+ require_relative 'uri/wss'
@@ -0,0 +1,17 @@
1
+ task :sync_tool, [:from] do |t, from: nil|
2
+ from ||= (File.identical?(__dir__, "rakelib") ? "../ruby/tool" : File.dirname(__dir__))
3
+
4
+ require 'fileutils'
5
+
6
+ {
7
+ "rakelib/sync_tool.rake" => "rakelib",
8
+ "lib/core_assertions.rb" => "test/lib",
9
+ "lib/envutil.rb" => "test/lib",
10
+ "lib/find_executable.rb" => "test/lib",
11
+ "lib/helper.rb" => "test/lib",
12
+ }.each do |src, dest|
13
+ FileUtils.mkpath(dest)
14
+ FileUtils.cp "#{from}/#{src}", dest
15
+ rescue Errno::ENOENT
16
+ end
17
+ end
data/uri.gemspec CHANGED
@@ -12,16 +12,26 @@ Gem::Specification.new do |spec|
12
12
 
13
13
  spec.summary = %q{URI is a module providing classes to handle Uniform Resource Identifiers}
14
14
  spec.description = spec.summary
15
- spec.homepage = "https://github.com/ruby/uri"
15
+
16
+ github_link = "https://github.com/ruby/uri"
17
+
18
+ spec.homepage = github_link
16
19
  spec.licenses = ["Ruby", "BSD-2-Clause"]
17
20
 
18
- spec.metadata["homepage_uri"] = spec.homepage
19
- spec.metadata["source_code_uri"] = spec.homepage
21
+ spec.required_ruby_version = '>= 2.5'
22
+
23
+ spec.metadata = {
24
+ "bug_tracker_uri" => "#{github_link}/issues",
25
+ "changelog_uri" => "#{github_link}/releases",
26
+ "documentation_uri" => "https://ruby.github.io/uri/",
27
+ "homepage_uri" => spec.homepage,
28
+ "source_code_uri" => github_link
29
+ }
20
30
 
21
31
  # Specify which files should be added to the gem when it is released.
22
32
  # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
23
33
  spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
24
- `git ls-files -z 2>/dev/null`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
34
+ `git ls-files -z 2>#{IO::NULL}`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
25
35
  end
26
36
  spec.bindir = "exe"
27
37
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
metadata CHANGED
@@ -1,14 +1,13 @@
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.13.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Akira Yamada
8
- autorequire:
9
8
  bindir: exe
10
9
  cert_chain: []
11
- date: 2023-06-29 00:00:00.000000000 Z
10
+ date: 1980-01-02 00:00:00.000000000 Z
12
11
  dependencies: []
13
12
  description: URI is a module providing classes to handle Uniform Resource Identifiers
14
13
  email:
@@ -17,6 +16,8 @@ executables: []
17
16
  extensions: []
18
17
  extra_rdoc_files: []
19
18
  files:
19
+ - ".github/dependabot.yml"
20
+ - ".github/workflows/gh-pages.yml"
20
21
  - ".github/workflows/test.yml"
21
22
  - ".gitignore"
22
23
  - Gemfile
@@ -40,15 +41,18 @@ files:
40
41
  - lib/uri/version.rb
41
42
  - lib/uri/ws.rb
42
43
  - lib/uri/wss.rb
44
+ - rakelib/sync_tool.rake
43
45
  - uri.gemspec
44
46
  homepage: https://github.com/ruby/uri
45
47
  licenses:
46
48
  - Ruby
47
49
  - BSD-2-Clause
48
50
  metadata:
51
+ bug_tracker_uri: https://github.com/ruby/uri/issues
52
+ changelog_uri: https://github.com/ruby/uri/releases
53
+ documentation_uri: https://ruby.github.io/uri/
49
54
  homepage_uri: https://github.com/ruby/uri
50
55
  source_code_uri: https://github.com/ruby/uri
51
- post_install_message:
52
56
  rdoc_options: []
53
57
  require_paths:
54
58
  - lib
@@ -56,15 +60,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
56
60
  requirements:
57
61
  - - ">="
58
62
  - !ruby/object:Gem::Version
59
- version: '0'
63
+ version: '2.5'
60
64
  required_rubygems_version: !ruby/object:Gem::Requirement
61
65
  requirements:
62
66
  - - ">="
63
67
  - !ruby/object:Gem::Version
64
68
  version: '0'
65
69
  requirements: []
66
- rubygems_version: 3.3.26
67
- signing_key:
70
+ rubygems_version: 3.8.0.dev
68
71
  specification_version: 4
69
72
  summary: URI is a module providing classes to handle Uniform Resource Identifiers
70
73
  test_files: []