Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save ValchanOficial/8df01b193c4bff31512e86773fe045e6 to your computer and use it in GitHub Desktop.
Save ValchanOficial/8df01b193c4bff31512e86773fe045e6 to your computer and use it in GitHub Desktop.
[Javascript] Get image name from url
const url = 'https://valchan.com.br/static/59fef712836ff3c9af18106e6daea978/3554d/valchan.webp'
const imageName = url.split('/').pop().split('.').shift()
const imageName2 = url.split('/').pop().replace(/\.[^/.]+$/, "")
console.log(imageName) // valchan
console.log(imageName2) // valchan
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment