Urara-Blog/node_modules/.pnpm-store/v3/files/4c/2b06c24aa2794c7e36b6e1d8d4e1699f9343fe323ce01f5a9144503fb913db877ef7b2a1488ecc97b26083f69a94f0e5b2f1c2598c1212b2986deafbe0f6be
2022-08-14 01:14:53 +08:00

25 lines
771 B
Text

'use strict';
Object.defineProperty(exports, '__esModule', { value: true });
const regex = /\sid="(\S+)"/g;
const randomPrefix = "IconifyId" + Date.now().toString(16) + (Math.random() * 16777216 | 0).toString(16);
let counter = 0;
function replaceIDs(body, prefix = randomPrefix) {
const ids = [];
let match;
while (match = regex.exec(body)) {
ids.push(match[1]);
}
if (!ids.length) {
return body;
}
ids.forEach((id) => {
const newID = typeof prefix === "function" ? prefix(id) : prefix + (counter++).toString();
const escapedID = id.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
body = body.replace(new RegExp('([#;"])(' + escapedID + ')([")]|\\.[a-z])', "g"), "$1" + newID + "$3");
});
return body;
}
exports.replaceIDs = replaceIDs;