getBasicUsername method

String getBasicUsername()

Extracts the username from a Basic authentication value.

For Basic authentication, the value is typically in the format 'username:password'. This method returns the username part of the Basic authentication value.

Returns an empty string if the value does not contain a username and password.

Implementation

String getBasicUsername() {
  var arr = value.split(':');
  if (arr.length >= 2) {
    return arr[0];
  }

  return '';
}