[Solved] how do i split the url using split method by checking all the image extension


You can always try to do it like this;

var imgUrl = "http://sits/productimages/00670535922278.png?sw=350&sh=350;";

var splitterArray = ['.jpeg', '.png', '.jpg', '.gif'];

for (var i = 0; i < splitterArray.length; i++) {
  var imgUrlArray = imgUrl.split(splitterArray[i]);

  if (imgUrlArray.length > 1) {
    //Do your thing here
  }
}

You use a array of your extensions that will be checked, and i your string contains the extension your imgUrlArray will have a length grater than one.

1

solved how do i split the url using split method by checking all the image extension