UNPKG

infinity-forge

Version:
26 lines 902 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.generateRef = generateRef; exports.normalizeString = normalizeString; var get_pathname_ref_1 = require("./get-pathname-ref.js"); function generateRef(referenceID, router, isGlobal) { var _a; return ((isGlobal ? 'global' : normalizeString((_a = (0, get_pathname_ref_1.getPathnameRef)({ router: router })) === null || _a === void 0 ? void 0 : _a.page)) + '_' + normalizeString(referenceID)); } function normalizeString(input) { if (!input) { return ''; } return input .normalize('NFD') .replaceAll(/[\u0300-\u036f]/g, '') .replaceAll(/[^a-zA-Z0-9]/g, '_') .replaceAll(/_{2,}/g, '_') .replaceAll(/^_+|_+$/g, '') .replaceAll('-', '') .replaceAll('_', '') .toLowerCase(); } //# sourceMappingURL=generate_ref.js.map