Skip to content

Instantly share code, notes, and snippets.

@aflansburg
Last active October 11, 2017 15:44
Show Gist options
  • Save aflansburg/8b2c8d1b8ca3dd7d1afb428c9abc07f4 to your computer and use it in GitHub Desktop.
Save aflansburg/8b2c8d1b8ca3dd7d1afb428c9abc07f4 to your computer and use it in GitHub Desktop.
RC strip img uri from full url
const regex = /^(.*product)\/cache.*(\/[a-z]\/[a-z]\/.*)/g;
let testUri = window.prompt('Input the full image url to be cleaned:');
let m;
let uriArr = [];
let cleanUri;
while ((m = regex.exec(testUri)) !== null) {
if (m.index === regex.lastIndex) {
regex.lastIndex++;
}
uriArr.push(m[1]);
uriArr.push(m[2]);
cleanUri = uriArr.join('');
console.log(cleanUri);
window.prompt('CTRL+C/CMD+C to copy', cleanUri);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment