From 0528afce07eeff4163494d25406ee9f7cc586ad0 Mon Sep 17 00:00:00 2001 From: Yuta Nagamiya Date: Wed, 21 Dec 2022 22:32:50 +0900 Subject: [PATCH] Support for multibyte characters --- resources/js/script.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/resources/js/script.js b/resources/js/script.js index fabe6d8..219808a 100644 --- a/resources/js/script.js +++ b/resources/js/script.js @@ -151,6 +151,11 @@ } function slugify(text){ + if (/[^\x01-\x7E\xA1-\xDF]/.test(text)) { + // If the text contains multibyte characters, do nothing + return text.toString(); + } + return text.toString().toLowerCase() .replace(/\s+/g, '-') // Replace spaces with - .replace(/[^\w\-]+/g, '') // Remove all non-word chars