UNPKG

urns

Version:

An RFC 8141 compliant URN library with some interesting type related functionality

24 lines (23 loc) 733 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.equivalent = void 0; var parser_1 = require("./parser"); /** * This is testing for equivalence as defined in Section 3 of RFC 8141 * * @param a First URN * @param b Second URN * @returns boolean */ function equivalent(a, b) { /** Parse both URNs */ var ap = parser_1.parseURN(a); var bp = parser_1.parseURN(b); /** * We only pay attention to the NID and the NSS, all other components are * ignored (per RFC 8141). Furthermore, the NID comparison is case insensitive. */ return (ap.nid.toLowerCase() === bp.nid.toLowerCase() && ap.nss_encoded === bp.nss_encoded); } exports.equivalent = equivalent;