URL parser in JavaScript