Allow underscore on slugify

This commit is contained in:
Kiril Videlov 2024-10-24 11:03:16 +02:00
parent dcd6391c88
commit 2f62bad734
2 changed files with 5 additions and 1 deletions

View File

@ -35,6 +35,10 @@ describe.concurrent('branch slugify with valid characters', () => {
test('numbers are fine', () => {
expect(slugify('my/branch1')).toEqual('my/branch1');
});
test('underscores are fine', () => {
expect(slugify('my_branch')).toEqual('my_branch');
});
});
describe.concurrent('branch slugify with replaced characters', () => {

View File

@ -44,7 +44,7 @@ export function slugify(input: string) {
.normalize('NFKD')
.replace(/[\u0300-\u036f]/g, '')
.trim()
.replace(/[^A-Za-z0-9/ -]/g, '')
.replace(/[^A-Za-z0-9_/ -]/g, '')
.replace(/\s+/g, '-')
.replace(/-+/g, '-');
}