I need to verify an image url to check whether the url is an image of any of these extensions:- jpeg, jpg, gif, png. Example:- when we verify this url http://www.example.com
let url = "folder/myImage.png";
if ( isValidImageURL(url) ){
// do something if url is valid image url.
}
function isValidImageURL(str){
if ( typeof str !== 'string' ) return false;
return !!str.match(/\w+\.(jpg|jpeg|gif|png|tiff|bmp)$/gi);
}