From f0cf73f0d313d50d703af5d35c261eacf3ab52c6 Mon Sep 17 00:00:00 2001 From: LB Johnston Date: Sat, 6 Apr 2024 15:42:55 +1000 Subject: [PATCH] Standardize on `allowUnicode` for slugify util option - This is the name used in the urlify util --- client/src/controllers/SlugController.ts | 4 ++-- client/src/utils/slugify.test.js | 2 +- client/src/utils/slugify.ts | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/client/src/controllers/SlugController.ts b/client/src/controllers/SlugController.ts index 968d42b59b..ddb8539503 100644 --- a/client/src/controllers/SlugController.ts +++ b/client/src/controllers/SlugController.ts @@ -63,9 +63,9 @@ export class SlugController extends Controller { event: CustomEvent<{ value: string }> | { detail: { value: string } }, ignoreUpdate = false, ) { - const unicodeSlugsEnabled = this.allowUnicodeValue; + const allowUnicode = this.allowUnicodeValue; const { value = this.element.value } = event?.detail || {}; - const newValue = slugify(value.trim(), { unicodeSlugsEnabled }); + const newValue = slugify(value.trim(), { allowUnicode }); if (!ignoreUpdate) { this.element.value = newValue; diff --git a/client/src/utils/slugify.test.js b/client/src/utils/slugify.test.js index 897093a92b..3987268acb 100644 --- a/client/src/utils/slugify.test.js +++ b/client/src/utils/slugify.test.js @@ -12,7 +12,7 @@ describe('slugify', () => { }); describe('slugify with unicode slugs enabled', () => { - const options = { unicodeSlugsEnabled: true }; + const options = { allowUnicode: true }; it('should return a correct slug', () => { expect(slugify('The Price is $72.00!', options)).toBe( diff --git a/client/src/utils/slugify.ts b/client/src/utils/slugify.ts index a926ceb47c..ee10927dcf 100644 --- a/client/src/utils/slugify.ts +++ b/client/src/utils/slugify.ts @@ -4,9 +4,9 @@ */ export const slugify = ( value: string, - { unicodeSlugsEnabled = false }: { unicodeSlugsEnabled?: boolean } = {}, + { allowUnicode = false }: { allowUnicode?: boolean } = {}, ) => - unicodeSlugsEnabled + allowUnicode ? value .replace(/\s+/g, '-') .replace(/[&/\\#,+()$~%.'":`@^!*?<>{}]/g, '')