Project

General

Profile

Bug #12212

Parsing a URI of "mailto:?subject=hi" with `URI.parse` raises an exception

Added by madeofcode (Mark Dodwell) over 4 years ago. Updated about 1 year ago.

Status:
Closed
Priority:
Normal
Assignee:
-
Target version:
-
[ruby-core:74527]

Description

Parsing a URI of "mailto:?subject=hi" with URI.parse raises an exception. I believe this is a valid "mailto" URI, as defined in RFC6068.

Behavior observed:

>> URI.parse("mailto:?subject=hi")
NoMethodError: undefined method `split' for nil:NilClass

Behavior expected:

>> uri = URI.parse("mailto:?subject=hi")
=> #<URI::MailTo URL:mailto:?subject=hi>
>> uri.to
=> ""
>> uri.headers
=> [["subject", "hi"]]

Reference from RFC6068 than defines the "to" element as optional:

mailtoURI = "mailto:" [ to ] [ hfields ]

https://tools.ietf.org/html/rfc6068#section-2

Patch attached.


Files

Also available in: Atom PDF