fix: handle malformed URNs without throwing - #211
Conversation
Normalize and equal now treat an ordinary URN that fails scheme-specific parsing (missing nid) as malformed input: normalize preserves the original string unchanged and equal returns false, instead of surfacing an uncaught 'URN without nid cannot be serialized' error. Resolve rejects the malformed scheme-specific input with a clear error. This is the follow-up to the URN parsing anchoring in #203, which now rejects more malformed inputs and so exposed the throw path.
Tony133
left a comment
There was a problem hiding this comment.
LGTM! A small, non-blocking suggestion: it might be worth adding a test that calls resolve() with an invalid URN to check the actual error message, since that path is currently only covered indirectly. What do you think?
|
Implemented Tony's suggestion: added a Note: |
|
There are conflicts in the |
…throw # Conflicts: # test/malformed-urn.test.js
Normalize and equal now treat an ordinary URN that fails scheme-specific parsing (a missing nid) as malformed input instead of surfacing an uncaught
URN without nid cannot be serializederror.normalizepreserves the original malformed string unchangedequalreturnsfalseinstead of throwingresolverejects the malformed scheme-specific input with a clearURI is malformed.errorThis is the follow-up to the URN parsing anchoring in #203, which now rejects more malformed inputs and so exposed the throw path. A new
malformedSchemeSpecificstatus flag is threaded through the status-carrying helpers (parseWithStatus,normalizeStringWithStatus,normalizeComparableURI,resolve).