getting the last segment of url

const parts = props.location.pathname.split('/');

const lastSegment = parts.pop() || parts.pop();

alert(lastSegment) 

Comments