Excluded files path setting's value is not evaluated properly
Opened this issue · 0 comments
Issue:
The value of the setting script path to ignore
is not properly evaluated in the backend which can lead to all scripts being excluded from being optimized.
Suppose we provide the value of that filed as lndo
. Now my site's URL is http://rtcamp.lndo.site
, so any scripts' URL will be something like http://rtcamp.lndo.site/path/to/the/file
.
Now in the backend, a simple strpos
is used to check if the value we have provided (e.g lndo
) is present in the URL or not. So, because of this logic, in all the scripts' URLs, this value is found and all the scripts are ignored.
So, basically if the supplied settings value matches even the smallest part of the resource URL then it will be ignored, which actually we don't intend to do here.
Fix:
User should be able to provide the complete path of the file ( e.g /path/to/file
) and then in the backend, we should prepend it with the site URL and then ultimately from a proper regular expression ( considering query parameters, etc. ) and then match against the path of the resource. If that regex match returns a true then only the file should be excluded and otherwise not.