mirror of
https://github.com/node-red/node-red.git
synced 2023-10-10 13:36:53 +02:00
Fix creds in URL
This commit is contained in:
parent
972c83cd52
commit
81f0fb3c74
@ -205,23 +205,25 @@ module.exports = function(RED) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
var parsedURL = new URL(url)
|
||||||
|
if (parsedURL.username) {
|
||||||
|
this.credentials.user = parsedURL.username
|
||||||
|
}
|
||||||
|
if (parsedURL.password) {
|
||||||
|
this.credentials.password = parsedURL.password
|
||||||
|
}
|
||||||
if (Object.keys(this.credentials).length != 0) {
|
if (Object.keys(this.credentials).length != 0) {
|
||||||
if (this.authType === "basic") {
|
if (this.authType === "basic") {
|
||||||
// Workaround for https://github.com/sindresorhus/got/issues/1169
|
// Workaround for https://github.com/sindresorhus/got/issues/1169
|
||||||
var cred = ""
|
var cred = ""
|
||||||
var parsedURL = new URL(url)
|
|
||||||
if (this.credentials.user) {
|
if (this.credentials.user) {
|
||||||
// opts.username = this.credentials.user;
|
// opts.username = this.credentials.user;
|
||||||
cred = this.credentials.user
|
cred = this.credentials.user
|
||||||
} else if (parsedURL.username) {
|
}
|
||||||
cred = parsedURL.username
|
|
||||||
}
|
|
||||||
if (this.credentials.password) {
|
if (this.credentials.password) {
|
||||||
// opts.password = this.credentials.password;
|
// opts.password = this.credentials.password;
|
||||||
cred += ":" + this.credentials.password
|
cred += ":" + this.credentials.password
|
||||||
} else if (parsedURL.password) {
|
}
|
||||||
cred += ":" + parsedURL.password
|
|
||||||
}
|
|
||||||
// build own basic auth header
|
// build own basic auth header
|
||||||
opts.headers.Authorization = "Basic " + Buffer.from(cred).toString("base64");
|
opts.headers.Authorization = "Basic " + Buffer.from(cred).toString("base64");
|
||||||
} else if (this.authType === "digest") {
|
} else if (this.authType === "digest") {
|
||||||
|
Loading…
Reference in New Issue
Block a user