Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/generators/metadata/constants.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -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: /(?<!^-*)-+$/g, to: '' }, // Remove any trailing hyphens
{ from: /^(?!-+$).*?(--+)/g, to: '-' }, // Replace multiple hyphens
Expand Down
8 changes: 4 additions & 4 deletions src/generators/metadata/utils/__tests__/slugger.test.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ describe('slug', () => {
});

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', () => {
Expand Down Expand Up @@ -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', () => {
Expand Down
Loading