FIX: Remove unnecessary forward slashes in regex

FIX: Remove unnecessary forward slashes in regex

diff --git a/app/assets/javascripts/discourse/app/lib/utilities.js b/app/assets/javascripts/discourse/app/lib/utilities.js
index 439b521..2c108e0 100644
--- a/app/assets/javascripts/discourse/app/lib/utilities.js
+++ b/app/assets/javascripts/discourse/app/lib/utilities.js
@@ -352,7 +352,7 @@ export function toAsciiPrintable(string, fallback) {
     string = string.normalize("NFD").replace(/[\u0300-\u036f]/g, "");
   }
 
-  return /^[/\040-\176/]*$/.test(string) ? string : fallback;
+  return /^[\040-\176]*$/.test(string) ? string : fallback;
 }
 
 export function slugify(string) {

GitHub sha: 6f228b03

This looks right to me, but also looks like something that should be very straightforward to test. Can we add a test for slugify?

1 Like

“FIX” may have been the wrong label since nothing was technically broken. It was just some regex polishing. This was actually for toAsciiPrintable, but I did make sure to include tests for both toAsciiPrintable and slugify with the initial PR.

1 Like