Skip to content

Commit 6bcf086

Browse files
committed
fix: treat non-http/https login urls as invalid
1 parent ba0373b commit 6bcf086

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

lib/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ const url = require('url')
2323
const isValidUrl = u => {
2424
if (u && typeof u === 'string') {
2525
const p = url.parse(u)
26-
return !!(p.protocol && p.slashes && p.host && p.path)
26+
return p.slashes && p.host && p.path && /^https?:$/.test(p.protocol)
2727
}
2828
return false
2929
}

lib/test/login.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ const server = http.createServer((q, s) => {
137137

138138
case '/invalid-login-url/-/v1/login':
139139
return respond(s, 200, {
140-
loginUrl: 'this is not a url',
140+
loginUrl: 'ftp://this.is/not-a-webpage/now/is/it?',
141141
doneUrl: reg + '/invalid-done/-/v1/login'
142142
})
143143

@@ -418,7 +418,7 @@ t.test('fail at login step by having an invalid url', t => {
418418
method: 'POST',
419419
uri: reg + '/invalid-login-url/-/v1/login',
420420
body: {
421-
loginUrl: 'this is not a url',
421+
loginUrl: 'ftp://this.is/not-a-webpage/now/is/it?',
422422
doneUrl: reg + '/invalid-done/-/v1/login'
423423
},
424424
message: 'Invalid response from web login endpoint'

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy