.pop obter o segundo elemento de url

var parts = 'http://mywebsite/folder/file'.split('/');
var lastSegment = parts.pop(1) || parts.pop();  // handle potential trailing slash

console.log(lastSegment);
 Run code snippetHide results
Tired Tarsier