diff --git a/src/generators/metadata/constants.mjs b/src/generators/metadata/constants.mjs index 93bc6765..14d22757 100644 --- a/src/generators/metadata/constants.mjs +++ b/src/generators/metadata/constants.mjs @@ -11,9 +11,9 @@ export const DOC_API_SLUGS_REPLACEMENTS = [ { from: /node.js/i, to: 'nodejs' }, // Replace Node.js { from: /&/, to: '-and-' }, // Replace & { from: /[/,:;\\ ]/g, to: '-' }, // Replace /,:;\. and whitespace - { from: /^-+(?!-*$)/g, to: '' }, // Remove any leading hyphens + { from: /^-(?!-|$)/g, to: '' }, // Remove a single leading hyphen { from: /(? { assert.strictEqual(slug('-foo', identity), 'foo'); }); - it('removes multiple leading hyphens', () => { - assert.strictEqual(slug('--foo', identity), 'foo'); + it('preserves multiple leading hyphens', () => { + assert.strictEqual(slug('--permission', identity), '--permission'); }); it('preserves an all-hyphen string', () => { @@ -78,6 +78,10 @@ describe('slug', () => { it('does not fire on an all-hyphen string', () => { assert.strictEqual(slug('---', identity), '---'); }); + + it('does not collapse leading double hyphen flags', () => { + assert.strictEqual(slug('--allow-fs-read', identity), '--allow-fs-read'); + }); }); describe('integration with github-slugger', () => {