/** * CJS mock of `github-slugger` (v2 is ESM-only, which jest's CJS runtime * cannot require). Auto-applied to all test files via the root `__mocks__` * directory — no `jest.mock()` call needed. */ class Slugger { constructor() { this.seen = new Map(); } slug(value, maintainCase) { let slug = String(value).trim(); if (!maintainCase) slug = slug.toLowerCase(); slug = slug .replace(/[^\p{L}\p{N}\s_-]/gu, "") .replace(/\s/g, "-"); // github-slugger dedups repeated slugs with a -1, -2, ... suffix const count = this.seen.get(slug) || 0; this.seen.set(slug, count + 1); if (count > 0) return `${slug}-${count}`; return slug; } } module.exports = Slugger;