summaryrefslogtreecommitdiff
path: root/lib/uri/common.rb
diff options
context:
space:
mode:
authorknu <knu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2007-02-15 02:41:45 +0000
committerknu <knu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2007-02-15 02:41:45 +0000
commitdb38fea37fb2f40399cac3b239f4955d78f8347c (patch)
treea4cfecfc0204110a8fc937e1209f8555cb29439d /lib/uri/common.rb
parent713920f74eed65b16f777bd76f56098ea927aee0 (diff)
* lib/uri/generic.rb (URI::Generic::userinfo): should support
empty password. [ruby-core:10290] * lib/uri/generic.rb (URI::Generic::set_password): password can be cleared by nil. [ruby-core:10290] * lib/uri/common.rb (escape): regard second string argument as a character set properly. [ruby-dev:27692] * lib/uri: Lovely RDOC patches from mathew (metaATpoboxDOTcom). git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@11747 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'lib/uri/common.rb')
-rw-r--r--lib/uri/common.rb8
1 files changed, 6 insertions, 2 deletions
diff --git a/lib/uri/common.rb b/lib/uri/common.rb
index ccf57bd93b..f74f0eb2e1 100644
--- a/lib/uri/common.rb
+++ b/lib/uri/common.rb
@@ -261,6 +261,7 @@ module URI
# +unsafe+::
# Regexp that matches all symbols that must be replaced with codes.
# By default uses <tt>REGEXP::UNSAFE</tt>.
+ # When this argument is a String, it represents a character set.
#
# == Description
#
@@ -277,10 +278,13 @@ module URI
# p URI.unescape(enc_uri)
# # => "http://example.com/?a=\t\r"
#
+ # p URI.escape("@?@!", "!?")
+ # # => "@%3F@%21"
+ #
def escape(str, unsafe = UNSAFE)
unless unsafe.kind_of?(Regexp)
# perhaps unsafe is String object
- unsafe = Regexp.new(Regexp.quote(unsafe), false, 'N')
+ unsafe = Regexp.new("[#{Regexp.quote(unsafe)}]", false, 'N')
end
str.gsub(unsafe) do |us|
tmp = ''
@@ -542,7 +546,7 @@ module URI
# require "uri"
#
# URI.extract("text here http://foo.example.org/bla and here mailto:test@example.com and here also.")
- # # => ["http://foo.example.org/bla", "mailto:test@example.com"]
+ # # => ["http://foo.example.com/bla", "mailto:test@example.com"]
#
def self.extract(str, schemes = nil, &block)
if block_given?