fix: allow periods in git refs through slugify()

This commit is contained in:
ndom91 2024-10-30 15:01:57 +01:00 committed by Nico Domino
parent ef3511c8c7
commit 5b355935a0
2 changed files with 5 additions and 1 deletions

View File

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

View File

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