diff --git a/src/generators/metadata/constants.mjs b/src/generators/metadata/constants.mjs index 614b30ef..e8ac140b 100644 --- a/src/generators/metadata/constants.mjs +++ b/src/generators/metadata/constants.mjs @@ -6,7 +6,7 @@ export const IGNORE_STABILITY_STEMS = ['documentation']; 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: '-' }, // Replace /,:;\. and whitespace { from: /^-+(?!-*$)/g, to: '' }, // Remove any leading hyphens { from: /(? { }); describe('special character to hyphen replacement', () => { - it('replaces underscores with hyphens', () => { - assert.strictEqual(slug('foo_bar', identity), 'foo-bar'); + it('preserves underscores', () => { + assert.strictEqual(slug('foo_bar', identity), 'foo_bar'); }); it('replaces forward slashes with hyphens', () => { @@ -85,8 +85,8 @@ describe('slug', () => { assert.strictEqual(slug('Hello World'), 'hello-world'); }); - it('converts underscored names to hyphenated slugs', () => { - assert.strictEqual(slug('child_process'), 'child-process'); + it('preserves underscores in module names', () => { + assert.strictEqual(slug('child_process'), 'child_process'); }); it('handles titles with no special characters', () => {