summaryrefslogtreecommitdiff
path: root/lib/uri
diff options
context:
space:
mode:
authordrbrain <drbrain@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2011-05-18 21:19:18 +0000
committerdrbrain <drbrain@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2011-05-18 21:19:18 +0000
commit7bbf2f308580f468802cd7d32c94fce1b9f1779e (patch)
tree0a680f59e70a78d60e776d7b763e618fb2fec624 /lib/uri
parent34276148c4450faa77bb298cfbe005f7c263f802 (diff)
* lib: Convert tabs to spaces for ruby files per
http://redmine.ruby-lang.org/projects/ruby/wiki/DeveloperHowto#coding-style Patch by Steve Klabnik [Ruby 1.9 - Bug #4730] Patch by Jason Dew [Ruby 1.9 - Feature #4718] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@31635 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'lib/uri')
-rw-r--r--lib/uri/common.rb138
-rw-r--r--lib/uri/generic.rb14
2 files changed, 77 insertions, 75 deletions
diff --git a/lib/uri/common.rb b/lib/uri/common.rb
index 56c6946f28..10f77caecb 100644
--- a/lib/uri/common.rb
+++ b/lib/uri/common.rb
@@ -120,71 +120,71 @@ module URI
def split(uri)
case uri
when ''
- # null uri
+ # null uri
when @regexp[:ABS_URI]
- scheme, opaque, userinfo, host, port,
- registry, path, query, fragment = $~[1..-1]
+ scheme, opaque, userinfo, host, port,
+ registry, path, query, fragment = $~[1..-1]
- # URI-reference = [ absoluteURI | relativeURI ] [ "#" fragment ]
+ # URI-reference = [ absoluteURI | relativeURI ] [ "#" fragment ]
- # absoluteURI = scheme ":" ( hier_part | opaque_part )
- # hier_part = ( net_path | abs_path ) [ "?" query ]
- # opaque_part = uric_no_slash *uric
+ # absoluteURI = scheme ":" ( hier_part | opaque_part )
+ # hier_part = ( net_path | abs_path ) [ "?" query ]
+ # opaque_part = uric_no_slash *uric
- # abs_path = "/" path_segments
- # net_path = "//" authority [ abs_path ]
+ # abs_path = "/" path_segments
+ # net_path = "//" authority [ abs_path ]
- # authority = server | reg_name
- # server = [ [ userinfo "@" ] hostport ]
+ # authority = server | reg_name
+ # server = [ [ userinfo "@" ] hostport ]
- if !scheme
- raise InvalidURIError,
- "bad URI(absolute but no scheme): #{uri}"
- end
- if !opaque && (!path && (!host && !registry))
- raise InvalidURIError,
- "bad URI(absolute but no path): #{uri}"
- end
+ if !scheme
+ raise InvalidURIError,
+ "bad URI(absolute but no scheme): #{uri}"
+ end
+ if !opaque && (!path && (!host && !registry))
+ raise InvalidURIError,
+ "bad URI(absolute but no path): #{uri}"
+ end
when @regexp[:REL_URI]
- scheme = nil
- opaque = nil
-
- userinfo, host, port, registry,
- rel_segment, abs_path, query, fragment = $~[1..-1]
- if rel_segment && abs_path
- path = rel_segment + abs_path
- elsif rel_segment
- path = rel_segment
- elsif abs_path
- path = abs_path
- end
+ scheme = nil
+ opaque = nil
+
+ userinfo, host, port, registry,
+ rel_segment, abs_path, query, fragment = $~[1..-1]
+ if rel_segment && abs_path
+ path = rel_segment + abs_path
+ elsif rel_segment
+ path = rel_segment
+ elsif abs_path
+ path = abs_path
+ end
- # URI-reference = [ absoluteURI | relativeURI ] [ "#" fragment ]
+ # URI-reference = [ absoluteURI | relativeURI ] [ "#" fragment ]
- # relativeURI = ( net_path | abs_path | rel_path ) [ "?" query ]
+ # relativeURI = ( net_path | abs_path | rel_path ) [ "?" query ]
- # net_path = "//" authority [ abs_path ]
- # abs_path = "/" path_segments
- # rel_path = rel_segment [ abs_path ]
+ # net_path = "//" authority [ abs_path ]
+ # abs_path = "/" path_segments
+ # rel_path = rel_segment [ abs_path ]
- # authority = server | reg_name
- # server = [ [ userinfo "@" ] hostport ]
+ # authority = server | reg_name
+ # server = [ [ userinfo "@" ] hostport ]
else
- raise InvalidURIError, "bad URI(is not URI?): #{uri}"
+ raise InvalidURIError, "bad URI(is not URI?): #{uri}"
end
path = '' if !path && !opaque # (see RFC2396 Section 5.2)
ret = [
- scheme,
- userinfo, host, port, # X
- registry, # X
- path, # Y
- opaque, # Y
- query,
- fragment
+ scheme,
+ userinfo, host, port, # X
+ registry, # X
+ path, # Y
+ opaque, # Y
+ query,
+ fragment
]
return ret
end
@@ -202,22 +202,22 @@ module URI
#
# == Usage
#
- # p = URI::Parser.new
- # p.parse("ldap://ldap.example.com/dc=example?user=john")
- # #=> #<URI::LDAP:0x00000000b9e7e8 URL:ldap://ldap.example.com/dc=example?user=john>
+ # p = URI::Parser.new
+ # p.parse("ldap://ldap.example.com/dc=example?user=john")
+ # #=> #<URI::LDAP:0x00000000b9e7e8 URL:ldap://ldap.example.com/dc=example?user=john>
#
def parse(uri)
scheme, userinfo, host, port,
- registry, path, opaque, query, fragment = self.split(uri)
+ registry, path, opaque, query, fragment = self.split(uri)
if scheme && URI.scheme_list.include?(scheme.upcase)
- URI.scheme_list[scheme.upcase].new(scheme, userinfo, host, port,
+ URI.scheme_list[scheme.upcase].new(scheme, userinfo, host, port,
registry, path, opaque, query,
fragment, self)
else
- Generic.new(scheme, userinfo, host, port,
- registry, path, opaque, query,
- fragment, self)
+ Generic.new(scheme, userinfo, host, port,
+ registry, path, opaque, query,
+ fragment, self)
end
end
@@ -239,9 +239,9 @@ module URI
#
# :call-seq:
- # extract( str )
- # extract( str, schemes )
- # extract( str, schemes ) {|item| block }
+ # extract( str )
+ # extract( str, schemes )
+ # extract( str, schemes ) {|item| block }
#
# == Args
#
@@ -260,12 +260,12 @@ module URI
#
def extract(str, schemes = nil, &block)
if block_given?
- str.scan(make_regexp(schemes)) { yield $& }
- nil
+ str.scan(make_regexp(schemes)) { yield $& }
+ nil
else
- result = []
- str.scan(make_regexp(schemes)) { result.push $& }
- result
+ result = []
+ str.scan(make_regexp(schemes)) { result.push $& }
+ result
end
end
@@ -273,16 +273,16 @@ module URI
# unless +schemes+ is provided. Then it is a Regexp.union with self.pattern[:X_ABS_URI]
def make_regexp(schemes = nil)
unless schemes
- @regexp[:ABS_URI_REF]
+ @regexp[:ABS_URI_REF]
else
- /(?=#{Regexp.union(*schemes)}:)#{@pattern[:X_ABS_URI]}/x
+ /(?=#{Regexp.union(*schemes)}:)#{@pattern[:X_ABS_URI]}/x
end
end
#
# :call-seq:
- # escape( str )
- # escape( str, unsafe )
+ # escape( str )
+ # escape( str, unsafe )
#
# == Args
#
@@ -313,8 +313,8 @@ module URI
#
# :call-seq:
- # unescape( str )
- # unescape( str, unsafe )
+ # unescape( str )
+ # unescape( str, unsafe )
#
# == Args
#
@@ -365,7 +365,7 @@ module URI
# hostname = *( domainlabel "." ) toplabel [ "." ]
# reg-name = *( unreserved / pct-encoded / sub-delims ) # RFC3986
unless hostname
- ret[:HOSTNAME] = hostname = "(?:[a-zA-Z0-9\\-.]|%\\h\\h)+"
+ ret[:HOSTNAME] = hostname = "(?:[a-zA-Z0-9\\-.]|%\\h\\h)+"
end
# RFC 2373, APPENDIX B:
diff --git a/lib/uri/generic.rb b/lib/uri/generic.rb
index bd5594fc3c..78e3fc05f7 100644
--- a/lib/uri/generic.rb
+++ b/lib/uri/generic.rb
@@ -174,7 +174,7 @@ module URI
path, opaque,
query,
fragment,
- parser = DEFAULT_PARSER,
+ parser = DEFAULT_PARSER,
arg_check = false)
@scheme = nil
@user = nil
@@ -1321,11 +1321,13 @@ module URI
self.query, self.fragment, parser)
if rel.userinfo != oth.userinfo ||
- rel.host.to_s.downcase != oth.host.to_s.downcase ||
- rel.port != oth.port
- if self.userinfo.nil? && self.host.nil?
- return self, self.dup
- end
+ rel.host.to_s.downcase != oth.host.to_s.downcase ||
+ rel.port != oth.port
+
+ if self.userinfo.nil? && self.host.nil?
+ return self, self.dup
+ end
+
rel.set_port(nil) if rel.port == oth.default_port
return rel, rel
end