class method
URI::MailTo.new
(::String? scheme, ::String? userinfo, ::String? host, (::String | ::Integer)? port, nil registry, ::String? path, ::String? opaque, ::String? query, ::String? fragment, ?untyped parser, ?::boolish arg_check) -> ::URI::MailTo
new(*arg)
lib/uri/mailto.rb
View on GitHub ↗
# File tmp/rubies/ruby-4.0.0/lib/uri/mailto.rb, line 132
def initialize(*arg)
super(*arg)
@to = nil
@headers = []
# The RFC3986 parser does not normally populate opaque
@opaque = "?#{@query}" if @query && !@opaque
unless @opaque
raise InvalidComponentError,
"missing opaque part for mailto URL"
end
to, header = @opaque.split('?', 2)
# allow semicolon as a addr-spec separator
# http://support.microsoft.com/kb/820868
unless /\A(?:[^@,;]+@[^@,;]+(?:\z|[,;]))*\z/ =~ to
raise InvalidComponentError,
"unrecognised opaque part for mailtoURL: #{@opaque}"
end
if arg[10] # arg_check
self.to = to
self.headers = header
else
set_to(to)
set_headers(header)
end
end
Description
Creates a new URI::MailTo object from generic URL components with no syntax checking.
This method is usually called from URI::parse, which checks the validity of each component.