garycourt/uri-js

Incorrect parsed scheme

Closed this issue · 5 comments

Given urn:oasis:names:tc:SAML:2.0:assertion as the URI, the result of .parse is:

{ scheme: 'urn:oasis',
  userinfo: undefined,
  host: undefined,
  port: undefined,
  path: 'names:tc:SAML:2.0:assertion',
  query: undefined,
  fragment: undefined,
  reference: 'absolute' }

This is incorrect. The scheme should be urn and the path should be oasis:names:tc:SAML:2.0:assertion.

No, it's correct. urn can not be a scheme on it's own. See RFC 2141 Section 2.

Um, your citation is exactly saying that urn is the scheme:

All URNs have the following syntax (phrases enclosed in quotes are
REQUIRED):

                <URN> ::= "urn:" <NID> ":" <NSS>

where is the Namespace Identifier, and is the Namespace
Specific String. The leading "urn:" sequence is case-insensitive.
The Namespace ID determines the syntactic interpretation of the
Namespace Specific String (as discussed in [1]).

Further, see https://en.wikipedia.org/wiki/Uniform_Resource_Identifier#Examples

  urn:example:mammal:monotreme:echidna
  └┬┘ └──────────────┬───────────────┘
scheme              path

Actually, you're right. RFC 2141 Appendix A states:

The URN syntax has been defined so that URNs can be used in places where URLs are expected. A resolver that conforms to the current URL syntax specification [3] will extract a scheme value of "urn:" rather than a scheme value of "urn:<nid>".

My confusion was that <URN> (which includes <NID>) was the scheme. I'll try to get to it in the next couple days.

I understand. It's a very confusing bit of the spec. I'm only versed on it currently because I'm digging in to SAML garbage.

This has now been fixed.