You can use replace to change the address,
var currentAddress = "www.site.com/img-small-1.jpg";
var newAddress = currentAddress.replace("img-small-1.jpg", "img-large-1.jpg");
window.location.href = newAddress; // this will redirect to new address
solved How to change some part of address with javascript and navigate to that address?