A miniature URL path parsing utility. Receives a URL or URL path component string and either a numerical index of the desired part or a keword string for which to search the value within the path:
urlPath('140byt.es/user/atk', 1) // 'atk' urlPath('140byt.es/user/atk', 'user') // still 'atk'
What about (74 bytes) :
function(a,b){return(a=a.split(/:?\/+/))[+b===b||~(b=a.indexOf(b))?b+1:b]}
Or even (86 bytes) :
function(a,b){return(b=location.href.split(/:?\/+/))[+a===a||~(a=b.indexOf(a))?a+1:a]}
?
PS : in your example, "actual value" != "expected value".