FL_Rest::strip_spaces() is intended as "the poor man's" Javascript magnifier; it removes all white spaces in the Javascript. Unfortunately, it can introduce errors.
Some examples how bb-plugin/modules/post-grid/js/frontend.js is mangled by this method:
-
The lack of terminating semicolon on line 122 (which is valid JavaScript, although not recommend) creates syntax error when the white space is removed.
-
return path on line 160 is mangled to returnpath which gives syntax error.
-
The comment on line 215 will after removal of white spaces stretch to the end of the file.
One solution is to replace preg_replace('/[\n\r\t\s]/', '', $txt ) with
preg_replace(["/\s+[\r\n]/", "/[\r\n]\s+/", "/[\t ]+/"], ["\n", "\n ", " "], $txt )
Here is a patch doing just that:
`diff --git a/classes/class-fl-builder-rest.php b/classes/class-fl-builder-rest.php
index 7c294d3..606c119 100644
--- a/classes/class-fl-builder-rest.php
+++ b/classes/class-fl-builder-rest.php
@@ -18,6 +18,6 @@ final class FL_Rest{
}
static function strip_spaces( $txt ) {
- return preg_replace('/[\n\r\t\s]/', '', $txt );
+ return preg_replace(["/\s+[\r\n]/", "/[\r\n]\s+/", "/[\t ]+/"], ["\n", "\n ", " "], $txt );
}
}
FL_Rest::strip_spaces() is intended as "the poor man's" Javascript magnifier; it removes all white spaces in the Javascript. Unfortunately, it can introduce errors.
Some examples how
bb-plugin/modules/post-grid/js/frontend.jsis mangled by this method:The lack of terminating semicolon on line 122 (which is valid JavaScript, although not recommend) creates syntax error when the white space is removed.
return pathon line 160 is mangled toreturnpathwhich gives syntax error.The comment on line 215 will after removal of white spaces stretch to the end of the file.
One solution is to replace
preg_replace('/[\n\r\t\s]/', '', $txt )withHere is a patch doing just that: