fix: ensure job id is a clean string

This commit is contained in:
Carl-Gerhard Lindesvärd
2025-12-08 20:32:29 +01:00
parent 4e42689115
commit 969c0bc8fe
4 changed files with 27 additions and 10 deletions

View File

@@ -0,0 +1,10 @@
import { describe, expect, it } from 'vitest';
import { slug } from './slug';
describe('slug', () => {
it('should remove pipes from string', () => {
expect(slug('Hello || World, | Test å å ä ä')).toBe(
'hello-world-test-a-a-a-a',
);
});
});

View File

@@ -3,12 +3,13 @@ import _slugify from 'slugify';
const slugify = (str: string) => {
return _slugify(
str
.replace('å', 'a')
.replace('ä', 'a')
.replace('ö', 'o')
.replace('Å', 'A')
.replace('Ä', 'A')
.replace('Ö', 'O'),
.replaceAll('å', 'a')
.replaceAll('ä', 'a')
.replaceAll('ö', 'o')
.replaceAll('Å', 'A')
.replaceAll('Ä', 'A')
.replaceAll('Ö', 'O')
.replace(/\|+/g, '-'),
{ lower: true, strict: true, trim: true },
);
};