@@ -21,11 +21,11 @@ export function setUriThrowOnMissingScheme(value: boolean): boolean {
2121 return old ;
2222}
2323
24- function _validateUri ( ret : URI ) : void {
24+ function _validateUri ( ret : URI , _strict ?: boolean ) : void {
2525
2626 // scheme, must be set
2727 if ( ! ret . scheme ) {
28- if ( _throwOnMissingSchema ) {
28+ if ( _strict || _throwOnMissingSchema ) {
2929 throw new Error ( `[UriError]: Scheme is missing: {scheme: "", authority: "${ ret . authority } ", path: "${ ret . path } ", query: "${ ret . query } ", fragment: "${ ret . fragment } "}` ) ;
3030 } else {
3131 console . warn ( `[UriError]: Scheme is missing: {scheme: "", authority: "${ ret . authority } ", path: "${ ret . path } ", query: "${ ret . query } ", fragment: "${ ret . fragment } "}` ) ;
@@ -141,7 +141,7 @@ export class URI implements UriComponents {
141141 /**
142142 * @internal
143143 */
144- protected constructor ( scheme : string , authority ?: string , path ?: string , query ?: string , fragment ?: string ) ;
144+ protected constructor ( scheme : string , authority ?: string , path ?: string , query ?: string , fragment ?: string , _strict ?: boolean ) ;
145145
146146 /**
147147 * @internal
@@ -151,7 +151,7 @@ export class URI implements UriComponents {
151151 /**
152152 * @internal
153153 */
154- protected constructor ( schemeOrData : string | UriComponents , authority ?: string , path ?: string , query ?: string , fragment ?: string ) {
154+ protected constructor ( schemeOrData : string | UriComponents , authority ?: string , path ?: string , query ?: string , fragment ?: string , _strict ?: boolean ) {
155155
156156 if ( typeof schemeOrData === 'object' ) {
157157 this . scheme = schemeOrData . scheme || _empty ;
@@ -169,7 +169,7 @@ export class URI implements UriComponents {
169169 this . query = query || _empty ;
170170 this . fragment = fragment || _empty ;
171171
172- _validateUri ( this ) ;
172+ _validateUri ( this , _strict ) ;
173173 }
174174 }
175175
@@ -261,7 +261,7 @@ export class URI implements UriComponents {
261261 *
262262 * @param value A string which represents an URI (see `URI#toString`).
263263 */
264- public static parse ( value : string ) : URI {
264+ public static parse ( value : string , _strict : boolean = false ) : URI {
265265 const match = _regexp . exec ( value ) ;
266266 if ( ! match ) {
267267 return new _URI ( _empty , _empty , _empty , _empty , _empty ) ;
@@ -272,6 +272,7 @@ export class URI implements UriComponents {
272272 decodeURIComponent ( match [ 5 ] || _empty ) ,
273273 decodeURIComponent ( match [ 7 ] || _empty ) ,
274274 decodeURIComponent ( match [ 9 ] || _empty ) ,
275+ _strict
275276 ) ;
276277 }
277278
0 commit comments