Nice finding that bug.
For proof that it really is a bug, refer to RFC 3986, section 3.1 SchemeRFC 3986, section 3.1 Scheme:
Although schemes are case- insensitive, the canonical form is lowercase and documents that specify schemes must do so with lowercase letters. An implementation should accept uppercase letters as equivalent to lowercase in scheme names (e.g., allow "HTTP" as well as "http") for the sake of robustness but should only produce lowercase scheme names for consistency.
The comment-handling seems to work right.