Skip to content

Instantly share code, notes, and snippets.

@umkasanki
Forked from jserrao/url-segment.js
Created September 11, 2018 11:45
Show Gist options
  • Save umkasanki/840ccb671507163f0837c4eb885c7be4 to your computer and use it in GitHub Desktop.
Save umkasanki/840ccb671507163f0837c4eb885c7be4 to your computer and use it in GitHub Desktop.
Get Last Segment of a URL in Javascript
var pageURL = window.location.href;
var lastURLSegment = pageURL.substr(pageURL.lastIndexOf('/') + 1);
console.log(lastURLSegment);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment