@@ -32,6 +32,21 @@ interface UrlParts {
3232 */
3333 port ?: string ;
3434
35+ /**
36+ * Url credentials: username and password (if any).
37+ */
38+ credentials ?: string ;
39+
40+ /**
41+ * Url's username.
42+ */
43+ username ?: string ;
44+
45+ /**
46+ * Url's password.
47+ */
48+ password ?: string ;
49+
3550 /**
3651 * Url path.
3752 */
@@ -71,15 +86,21 @@ export class CoreUrl {
7186 return null ;
7287 }
7388
74- // Split host into domain and port.
7589 const host = match [ 4 ] || '' ;
76- const [ domain , port ] : string [ ] = host . indexOf ( ':' ) === - 1 ? [ host ] : host . split ( ':' ) ;
90+
91+ // Get the credentials and the port from the host.
92+ const [ domainAndPort , credentials ] : string [ ] = host . split ( '@' ) . reverse ( ) ;
93+ const [ domain , port ] : string [ ] = domainAndPort . split ( ':' ) ;
94+ const [ username , password ] : string [ ] = credentials ? credentials . split ( ':' ) : [ ] ;
7795
7896 // Prepare parts replacing empty strings with undefined.
7997 return {
8098 protocol : match [ 2 ] || undefined ,
8199 domain : domain || undefined ,
82100 port : port || undefined ,
101+ credentials : credentials || undefined ,
102+ username : username || undefined ,
103+ password : password || undefined ,
83104 path : match [ 5 ] || undefined ,
84105 query : match [ 7 ] || undefined ,
85106 fragment : match [ 9 ] || undefined ,
0 commit comments