1
- const { URL } = require ( 'url' ) ;
1
+ const url = require ( 'url' ) ;
2
2
3
3
const clone = require ( 'lodash/clone' ) ;
4
4
const without = require ( 'lodash/without' ) ;
@@ -474,7 +474,7 @@ module.exports = function getSchema(provider) {
474
474
if ( this . application_type === 'web' ) return ;
475
475
476
476
this . redirect_uris = this . redirect_uris . map ( ( redirectUri ) => {
477
- const parsed = new URL ( redirectUri ) ;
477
+ const parsed = new url . URL ( redirectUri ) ;
478
478
// remove the port component, making dynamic ports allowed for loopback uris
479
479
if ( parsed . protocol === 'http:' && LOOPBACKS . includes ( parsed . hostname ) ) {
480
480
parsed . port = 80 ; // http + 80 = no port part in the string
@@ -488,7 +488,7 @@ module.exports = function getSchema(provider) {
488
488
postLogoutRedirectUris ( ) {
489
489
this . post_logout_redirect_uris . forEach ( ( uri ) => {
490
490
try {
491
- new URL ( uri ) ; // eslint-disable-line no-new
491
+ new url . URL ( uri ) ; // eslint-disable-line no-new
492
492
} catch ( err ) {
493
493
invalidate ( 'post_logout_redirect_uris must only contain uris' ) ;
494
494
}
@@ -502,7 +502,7 @@ module.exports = function getSchema(provider) {
502
502
let protocol ;
503
503
504
504
try {
505
- ( { origin, protocol } = new URL ( uri ) ) ;
505
+ ( { origin, protocol } = new url . URL ( uri ) ) ;
506
506
} catch ( err ) {
507
507
invalidate ( 'web_message_uris must only contain valid uris' ) ;
508
508
}
@@ -517,16 +517,14 @@ module.exports = function getSchema(provider) {
517
517
518
518
redirectUris ( ) {
519
519
this . redirect_uris . forEach ( ( redirectUri ) => {
520
- let hostname ;
521
- let protocol ;
522
- let hash ;
523
-
524
520
try {
525
- ( { hash , hostname , protocol } = new URL ( redirectUri ) ) ;
521
+ new url . URL ( redirectUri ) ; // eslint-disable-line no-new
526
522
} catch ( err ) {
527
523
invalidate ( 'redirect_uris must only contain valid uris' ) ;
528
524
}
529
525
526
+ const { hash, hostname, protocol } = url . parse ( redirectUri ) ;
527
+
530
528
if ( hash ) {
531
529
invalidate ( 'redirect_uris must not contain fragments' ) ;
532
530
}
0 commit comments