Hi,
I want to test whether a URL request for file somefile.js
for example, if the url is http://mydomain.com/somefile.js then the test should be true.
The same way for
http://mydomain.com/somefile.js?someparameter=whatever&anotherparam=hello http://mydomain.com/somedirectory/somewhatever/somefile.js
How would I do that using regular expression?
Untested:
if(preg_match('/\.js($|\?)/', $url) { // request is for .js file }
Add an "i" after the second "/" if you want the test to be case-insensitive.
Thanks a lot.