Last active
August 23, 2017 08:43
-
-
Save Bizunow/919ef63b79fe1bac7bc4d48af7625694 to your computer and use it in GitHub Desktop.
[Get URL last segment] #js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// getLastUrlSegment('https://vk.com/ibizunov') // return 'ibizunov' | |
function getLastUrlSegment(url) { | |
const parts = url.split('/'); | |
return lastSegment = parts.pop() || parts.pop(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment