aboutsummaryrefslogtreecommitdiffstats
path: root/lib/uri/common.rb
diff options
context:
space:
mode:
authorakira <akira@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2002-10-04 06:26:45 +0000
committerakira <akira@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2002-10-04 06:26:45 +0000
commit05e476c941e41132d40b4bcbfcc7eea90cae7318 (patch)
treeabe5147994e8566c8c4f7f49e59378f9683df2d3 /lib/uri/common.rb
parent396c29d1952642868874cace40615c2f1aae153b (diff)
downloadruby-05e476c941e41132d40b4bcbfcc7eea90cae7318.tar.gz
updated uri.rb and uri/*.rb to uri-0.9.7
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@2934 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'lib/uri/common.rb')
-rw-r--r--lib/uri/common.rb44
1 files changed, 18 insertions, 26 deletions
diff --git a/lib/uri/common.rb b/lib/uri/common.rb
index ea7d3c8865..aabb887db2 100644
--- a/lib/uri/common.rb
+++ b/lib/uri/common.rb
@@ -151,8 +151,10 @@ module URI
(?:(#{PATTERN::HOST})(?::(\\d*))?))?(?# 3: host, 4: port)
|
(#{PATTERN::REG_NAME}) (?# 5: registry)
- ))?
- ((?!//)#{PATTERN::ABS_PATH})? (?# 6: path)
+ )
+ |
+ (?!//)) (?# XXX: '//' is the mark for hostport)
+ (#{PATTERN::ABS_PATH})? (?# 6: path)
)(?:\\?(#{PATTERN::QUERY}))? (?# 7: query)
|
(#{PATTERN::OPAQUE_PART}) (?# 8: opaque)
@@ -396,32 +398,22 @@ module URI
=end
def self.extract(str, schemes = [])
urls = []
- if schemes.size > 0
- tmp = Regexp.new('(?:' + schemes.collect{|s|
- Regexp.quote(s + ':')
- }.join('|') + ')',
- Regexp::IGNORECASE, 'N')
- str.scan(tmp) {
- tmp_str = $& + $'
- if ABS_URI_REF =~ tmp_str
- if block_given?
- yield($&)
- else
- urls << $&
- end
- end
- }
-
- else
- str.scan(ABS_URI_REF) {
- if block_given?
- yield($&)
- else
- urls << $&
- end
- }
+ regexp = ABS_URI_REF
+ unless schemes.empty?
+ regexp = Regexp.new('(?=' + schemes.collect{|s|
+ Regexp.quote(s + ':')
+ }.join('|') + ')' + PATTERN::X_ABS_URI,
+ Regexp::IGNORECASE, 'N')
end
+ str.scan(ABS_URI_REF) {
+ if block_given?
+ yield($&)
+ else
+ urls << $&
+ end
+ }
+
if block_given?
return nil
else