diff options
author | akira <akira@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2002-10-04 06:26:45 +0000 |
---|---|---|
committer | akira <akira@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2002-10-04 06:26:45 +0000 |
commit | cce94d4e655ca836a1fbc87729ce3a212de85f7f (patch) | |
tree | abe5147994e8566c8c4f7f49e59378f9683df2d3 /lib/uri/common.rb | |
parent | cd7e4071bd827cc6b81a65b2ed1830c0f98b6e7b (diff) | |
download | ruby-cce94d4e655ca836a1fbc87729ce3a212de85f7f.tar.gz ruby-cce94d4e655ca836a1fbc87729ce3a212de85f7f.tar.xz ruby-cce94d4e655ca836a1fbc87729ce3a212de85f7f.zip |
updated uri.rb and uri/*.rb to uri-0.9.7
git-svn-id: http://svn.ruby-lang.org/repos/ruby/trunk@2934 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'lib/uri/common.rb')
-rw-r--r-- | lib/uri/common.rb | 44 |
1 files changed, 18 insertions, 26 deletions
diff --git a/lib/uri/common.rb b/lib/uri/common.rb index ea7d3c886..aabb887db 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 |