Skip to content

Instantly share code, notes, and snippets.

@franklinjavier
Created December 27, 2018 11:39
Show Gist options
  • Save franklinjavier/ac041673490dd3e26b469ae9738c1db8 to your computer and use it in GitHub Desktop.
Save franklinjavier/ac041673490dd3e26b469ae9738c1db8 to your computer and use it in GitHub Desktop.
Regex to get cloudinary transformation from URL
const url = 'https://res.cloudinary.com/beleza-na-web/image/upload/w_1500,f_auto,fl_progressive,q_auto:eco,w_1800,c_limit/e_trim/v1/imagens/5/good-girl-carolina-herrera-eau-de-parfum-perfume-feminino-80ml-38271-1371676352244596349.jpg'
const transformationRE = /(\/(upload|fetch)\/)(.+?)(\/v\d+)/g
const [,,, transformation] = transformationRE.exec(url)
console.log(transformation)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment