JSFiddle - React, Tailwind, and code Playground

JavaScript

var testRegex = /^https?:\/\/(?:[a-z\-]+\.)+[a-z]{2,6}(?:\/[^\/#?]+)+\.(?:jpe?g|gif|png)$/;
var imageUrl1 = "http://stackoverflow.com/questions/406192/how-to-get-the-current-url-in-jquery";
var imageUrl2 = "http://stackoverflow.com/questions/406192/how-to-get-the-current-url-in-jquery.jpg";
if (!testRegex.test(imageUrl1)) {
    alert('imageUrl1 Not Match');
}
if (!testRegex.test(imageUrl2)) {
    alert('imageUrl2 Not Match');
}