Merge pull request #17999 from eileenmcnaughton/sql_cache
[civicrm-core.git] / CRM / Utils / JS.php
index 192a25ad09a31248773730b73d5567ae4bcdd721..27e52d0d1ffb0c86acaaa11ecd4a949654563178 100644 (file)
@@ -62,7 +62,7 @@ class CRM_Utils_JS {
    *   Ordered list of JS vars to identify the start of a closure.
    * @param array $inputVals
    *   Ordered list of input values passed into the closure.
-   * @return string
+   * @return string[]
    *   Javascript source.
    */
   public static function dedupeClosures($scripts, $localVars, $inputVals) {
@@ -109,7 +109,7 @@ class CRM_Utils_JS {
    * @return string
    */
   public static function stripComments($script) {
-    return preg_replace(":^\\s*//[^\n]+$:m", "", $script);
+    return preg_replace("#^\\s*//[^\n]*$(?:\r\n|\n)?#m", "", $script);
   }
 
   /**
@@ -126,6 +126,7 @@ class CRM_Utils_JS {
    *
    * @param string $js
    * @return mixed
+   * @throws Exception
    */
   public static function decode($js) {
     $js = trim($js);
@@ -189,7 +190,7 @@ class CRM_Utils_JS {
    *
    * @param $js
    * @return array
-   * @throws \Exception
+   * @throws Exception
    */
   public static function getRawProps($js) {
     $js = trim($js);