Skip to content

Instantly share code, notes, and snippets.

@islahh
Forked from jserrao/url-segment.js
Created September 22, 2020 07:20
Show Gist options
  • Save islahh/efadfb062d8122c6d0934ca9b2dbe36d to your computer and use it in GitHub Desktop.
Save islahh/efadfb062d8122c6d0934ca9b2dbe36d 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