mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* lib/uri/common.rb (Kernel#URI): new global method for parsing URIs.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@6584 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
1e610842fb
commit
b750470064
3 changed files with 21 additions and 0 deletions
|
@ -1,3 +1,7 @@
|
|||
Mon Jul 5 22:54:39 2004 Tanaka Akira <akr@m17n.org>
|
||||
|
||||
* lib/uri/common.rb (Kernel#URI): new global method for parsing URIs.
|
||||
|
||||
Mon Jul 5 09:02:52 2004 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||
|
||||
* eval.c (rb_thread_yield, rb_f_catch): 4th argument to rb_yield_0()
|
||||
|
|
|
@ -595,3 +595,13 @@ module URI
|
|||
end
|
||||
|
||||
end
|
||||
|
||||
module Kernel
|
||||
# alias for URI.parse.
|
||||
#
|
||||
# This method is introduced at 1.8.2.
|
||||
def URI(uri_str) # :doc:
|
||||
URI.parse(uri_str)
|
||||
end
|
||||
module_function :URI
|
||||
end
|
||||
|
|
|
@ -43,6 +43,13 @@ class TestCommon < Test::Unit::TestCase
|
|||
assert_equal nil, ':'.slice(URI.regexp)
|
||||
assert_equal 'From:', 'From:'.slice(URI.regexp)
|
||||
end
|
||||
|
||||
def test_kernel_uri
|
||||
expected = URI.parse("http://www.ruby-lang.org/")
|
||||
assert_equal(expected, URI("http://www.ruby-lang.org/"))
|
||||
assert_equal(expected, Kernel::URI("http://www.ruby-lang.org/"))
|
||||
assert_raise(NoMethodError) { Object.new.URI("http://www.ruby-lang.org/") }
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
|
|
Loading…
Reference in a new issue