How to use the username function from url

Find comprehensive JavaScript url.username code examples handpicked from public code repositorys.

6001
6002
6003
6004
6005
6006
6007
6008
6009
if (protocol && protocol.charAt(protocol.length - 1) !== ':') protocol += ':';

var result = protocol + (url.slashes || isSpecial(url.protocol) ? '//' : '');

if (url.username) {
  result += url.username;
  if (url.password) result += ':'+ url.password;
  result += '@';
}
fork icon0
star icon0
watch icon1