From 5fc84028e931031b87bc2dda0dbad12e570535ca Mon Sep 17 00:00:00 2001 From: Andrew Nicols Date: Thu, 12 Dec 2019 15:58:19 +0800 Subject: [PATCH] MDL-67327 js: Make requirejs.php more fault tolerant --- lib/requirejs.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/requirejs.php b/lib/requirejs.php index 49c0db77c46..46cace6e803 100644 --- a/lib/requirejs.php +++ b/lib/requirejs.php @@ -104,7 +104,7 @@ if ($rev > 0 and $rev < (time() + 60 * 60)) { $js = rtrim($js); $js .= "\n"; - if (preg_match('/define\(\s*\[/', $js)) { + if (preg_match('/define\(\s*(\[|function)/', $js)) { // If the JavaScript module has been defined without specifying a name then we'll // add the Moodle module name now. $replace = 'define(\'' . $modulename . '\', '; @@ -157,7 +157,7 @@ if (!empty($jsfiles)) { $js = rtrim($js); } - if (preg_match('/define\(\s*\[/', $js)) { + if (preg_match('/define\(\s*(\[|function)/', $js)) { // If the JavaScript module has been defined without specifying a name then we'll // add the Moodle module name now. $replace = 'define(\'' . $modulename . '\', ';