88 * @flow
99 */
1010
11- import type Blob from '. /Blob' ;
11+ import type Blob from 'react-native/Libraries/Blob /Blob' ;
1212
13- import NativeBlobModule from '. /NativeBlobModule' ;
13+ import NativeBlobModule from 'react-native/Libraries/Blob /NativeBlobModule' ;
1414
1515let BLOB_URL_PREFIX = null ;
1616
5252 * ```
5353 */
5454
55- export { URLSearchParams } from '. /URLSearchParams' ;
55+ export { URLSearchParams } from 'react-native/Libraries/Blob /URLSearchParams' ;
5656
5757function validateBaseUrl ( url : string ) {
5858 // from this MIT-licensed gist: https://gist.github.com/dperini/729294
@@ -72,6 +72,7 @@ export class URL {
7272 return `${ BLOB_URL_PREFIX } ${ blob . data . blobId } ?offset=${ blob . data . offset } &size=${ blob . size } ` ;
7373 }
7474
75+
7576 static revokeObjectURL ( url : string ) {
7677 // Do nothing.
7778 }
@@ -112,13 +113,14 @@ export class URL {
112113 }
113114
114115 get host ( ) : string {
115- const hostMatch = this . _url . match ( / ^ h t t p s ? : \/ \/ ( [ ^ : / ? # ] + ) / ) ;
116+ const hostMatch = this . _url . match ( / ^ h t t p s ? : \/ \/ (?: [ ^ @ ] + @ ) ? ( [ ^ : / ? # ] + ) / ) ;
116117 const portMatch = this . _url . match ( / : ( \d + ) (? = [ / ? # ] | $ ) / ) ;
118+
117119 return hostMatch ? hostMatch [ 1 ] + ( portMatch ? `:${ portMatch [ 1 ] } ` : '' ) : '' ;
118120 }
119121
120122 get hostname ( ) : string {
121- const hostnameMatch = this . _url . match ( / ^ h t t p s ? : \/ \/ ( [ ^ : / ? # ] + ) / ) ;
123+ const hostnameMatch = this . _url . match ( / ^ h t t p s ? : \/ \/ (?: [ ^ @ ] + @ ) ? ( [ ^ : / ? # ] + ) / ) ;
122124 return hostnameMatch ? hostnameMatch [ 1 ] : '' ;
123125 }
124126
@@ -136,6 +138,12 @@ export class URL {
136138 return passwordMatch ? passwordMatch [ 1 ] : '' ;
137139 }
138140
141+ get username ( ) : string {
142+
143+ const usernameMatch = this . _url . match ( / ^ h t t p s ? : \/ \/ ( [ ^ : @ ] + ) (?: : [ ^ @ ] * ) ? @ / ) ;
144+ return usernameMatch ? usernameMatch [ 1 ] : '' ;
145+ }
146+
139147 get pathname ( ) : string {
140148 const pathMatch = this . _url . match ( / h t t p s ? : \/ \/ [ ^ / ] + ( \/ [ ^ ? # ] * ) ? / ) ;
141149 return pathMatch ? pathMatch [ 1 ] || '/' : '/' ;
@@ -177,7 +185,4 @@ export class URL {
177185 return this . _url + separator + instanceString ;
178186 }
179187
180- get username ( ) : string {
181- throw new Error ( 'URL.username is not implemented' ) ;
182- }
183188}
0 commit comments