Skip to content

Instantly share code, notes, and snippets.

View RichardDillman's full-sized avatar

Richard Dillman RichardDillman

View GitHub Profile
@RichardDillman
RichardDillman / slugify.test.ts
Last active January 31, 2022 18:18
General Slugify function. Trim white-space. Replace all non-alphanumeric with dashes. Replace diacritics with generics Reduce chains of dashes to a single dash.
describe("slugify()", () => {
it("Must remove url encodings.", () => {
const result = slugify("New%20York, NY");
expect(result).toBe("new-york-ny");
});
it("Must replace non-alphanumerics with dashes.", () => {
const result = slugify("a@b");
expect(result).toBe("a-b");
});