From: Oluwatobiloba A. Adeneye <26242370@students.lincoln.ac.uk> Date: Sun, 7 May 2023 21:16:19 +0000 (+0100) Subject: fix(bug): add condition to prevent name is undefined in isLocaleNameSane function... X-Git-Tag: 2.30.0~24^2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=bee59ae7b2708410250590a52c87580804dcbde7;p=thirdparty%2Fmoment.git fix(bug): add condition to prevent name is undefined in isLocaleNameSane function and ensure it returns a boolean --- diff --git a/src/lib/locale/locales.js b/src/lib/locale/locales.js index b329b83b3..721594a22 100644 --- a/src/lib/locale/locales.js +++ b/src/lib/locale/locales.js @@ -64,7 +64,8 @@ function chooseLocale(names) { function isLocaleNameSane(name) { // Prevent names that look like filesystem paths, i.e contain '/' or '\' - return name.match('^[^/\\\\]*$') != null; + // Ensure name is available and function returns boolean + return !!(name && name.match('^[^/\\\\]*$')); } function loadLocale(name) {