Skip to content

Instantly share code, notes, and snippets.

@jserrao
Created July 27, 2016 14:41
Show Gist options
  • Save jserrao/40f7b18ea91f42af4687ab30ceaee004 to your computer and use it in GitHub Desktop.
Save jserrao/40f7b18ea91f42af4687ab30ceaee004 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);
@pasha1110
Copy link

Thank you bro, this tutorial saved my time!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment