File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -571,15 +571,19 @@ export class GrammarHandler {
571571 return undefined ;
572572 }
573573
574- const colonIndex : number = trimmed . indexOf ( ':' ) ;
575- if ( colonIndex !== - 1 ) {
576- const scheme : string = trimmed . substring ( 0 , colonIndex ) . toLowerCase ( ) ;
577- if ( scheme !== 'http' && scheme !== 'https' && scheme !== 'file' ) {
578- this . trace ( `Rejected schema location '${ trimmed } ' for namespace '${ namespace } ' due to unsupported scheme '${ scheme } '` ) ;
574+ if ( / ^ \w + : / . test ( trimmed ) ) {
575+ try {
576+ const parsed = new URL ( trimmed ) ;
577+ if ( ! [ 'http:' , 'https:' , 'file:' ] . includes ( parsed . protocol ) ) {
578+ this . trace ( `Rejected schema location '${ trimmed } ' for namespace '${ namespace } ' due to unsupported protocol '${ parsed . protocol } '` ) ;
579+ return undefined ;
580+ }
581+ return parsed . href ;
582+ } catch ( error ) {
583+ XMLUtils . ignoreUnused ( error ) ;
584+ this . trace ( `Rejected schema location '${ trimmed } ' for namespace '${ namespace } ' because it is not a valid URL` ) ;
579585 return undefined ;
580586 }
581- const remainder : string = trimmed . substring ( colonIndex ) ;
582- return scheme + remainder ;
583587 }
584588
585589 return trimmed ;
You can’t perform that action at this time.
0 commit comments