snipe/web/node_modules/@iconify/utils/lib/svg/id.js
pyr0ball 7a704441a6 feat(snipe): Vue 3 frontend scaffold + Docker web service
- web/: Vue 3 + Vite + UnoCSS + Pinia, dark tactical theme (amber/#0d1117)
- AppNav, ListingCard, SearchView with filters/sort, composables
  (useSnipeMode, useKonamiCode, useMotion), Pinia search store
- Steal shimmer, auction countdown, Snipe Mode easter egg all native in Vue
- docker/web/: nginx + multi-stage Dockerfile (node build → nginx serve)
- compose.yml: api (8510) + web (8509) services
- Dockerfile CMD updated to uvicorn for upcoming FastAPI layer
- Clean build: 0 TS errors, 380 modules
2026-03-25 15:11:35 -07:00

42 lines
No EOL
1,019 B
JavaScript

/**
* Regular expression for finding ids
*/
const regex = /\sid="(\S+)"/g;
/**
* Counters
*/
const counters = /* @__PURE__ */ new Map();
/**
* Get unique new ID
*/
function nextID(id) {
id = id.replace(/[0-9]+$/, "") || "a";
const count = counters.get(id) || 0;
counters.set(id, count + 1);
return count ? `${id}${count}` : id;
}
/**
* Replace IDs in SVG output with unique IDs
*/
function replaceIDs(body) {
const ids = [];
let match;
while (match = regex.exec(body)) ids.push(match[1]);
if (!ids.length) return body;
const suffix = "suffix" + (Math.random() * 16777216 | Date.now()).toString(16);
ids.forEach((id) => {
const newID = nextID(id);
const escapedID = id.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
body = body.replace(new RegExp("([#;\"])(" + escapedID + ")([\")]|\\.[a-z])", "g"), "$1" + newID + suffix + "$3");
});
body = body.replace(new RegExp(suffix, "g"), "");
return body;
}
/**
* Clear ID cache
*/
function clearIDCache() {
counters.clear();
}
export { clearIDCache, replaceIDs };