1- const { URL } = require ( 'url' ) ;
1+ const url = require ( 'url' ) ;
22
33const clone = require ( 'lodash/clone' ) ;
44const without = require ( 'lodash/without' ) ;
@@ -474,7 +474,7 @@ module.exports = function getSchema(provider) {
474474 if ( this . application_type === 'web' ) return ;
475475
476476 this . redirect_uris = this . redirect_uris . map ( ( redirectUri ) => {
477- const parsed = new URL ( redirectUri ) ;
477+ const parsed = new url . URL ( redirectUri ) ;
478478 // remove the port component, making dynamic ports allowed for loopback uris
479479 if ( parsed . protocol === 'http:' && LOOPBACKS . includes ( parsed . hostname ) ) {
480480 parsed . port = 80 ; // http + 80 = no port part in the string
@@ -488,7 +488,7 @@ module.exports = function getSchema(provider) {
488488 postLogoutRedirectUris ( ) {
489489 this . post_logout_redirect_uris . forEach ( ( uri ) => {
490490 try {
491- new URL ( uri ) ; // eslint-disable-line no-new
491+ new url . URL ( uri ) ; // eslint-disable-line no-new
492492 } catch ( err ) {
493493 invalidate ( 'post_logout_redirect_uris must only contain uris' ) ;
494494 }
@@ -502,7 +502,7 @@ module.exports = function getSchema(provider) {
502502 let protocol ;
503503
504504 try {
505- ( { origin, protocol } = new URL ( uri ) ) ;
505+ ( { origin, protocol } = new url . URL ( uri ) ) ;
506506 } catch ( err ) {
507507 invalidate ( 'web_message_uris must only contain valid uris' ) ;
508508 }
@@ -517,16 +517,14 @@ module.exports = function getSchema(provider) {
517517
518518 redirectUris ( ) {
519519 this . redirect_uris . forEach ( ( redirectUri ) => {
520- let hostname ;
521- let protocol ;
522- let hash ;
523-
524520 try {
525- ( { hash , hostname , protocol } = new URL ( redirectUri ) ) ;
521+ new url . URL ( redirectUri ) ; // eslint-disable-line no-new
526522 } catch ( err ) {
527523 invalidate ( 'redirect_uris must only contain valid uris' ) ;
528524 }
529525
526+ const { hash, hostname, protocol } = url . parse ( redirectUri ) ;
527+
530528 if ( hash ) {
531529 invalidate ( 'redirect_uris must not contain fragments' ) ;
532530 }
0 commit comments