File tree 1 file changed +17
-0
lines changed 1 file changed +17
-0
lines changed Original file line number Diff line number Diff line change @@ -5,6 +5,23 @@ export default class FailBot {
5
5
this . app = app
6
6
this . haystackURL = haystackURL
7
7
this . headers = headers
8
+
9
+ // Since we're using `node-fetch` we can't rely on it deconstructing the
10
+ // basic authentication credentials from the URL (e.g.
11
+ // https://user:pass@failbotdomain /path) because `node-fetch` will always
12
+ // strip it. See https://github.com/node-fetch/node-fetch/issues/1330
13
+ // and it's not a bug.
14
+ // The correct thing is to extract it manually and add an `Authorization`
15
+ // header based on it from the URL.
16
+ const url = new URL ( this . haystackURL )
17
+ const { username, password } = url
18
+ if ( username || password ) {
19
+ this . headers . Authorization = `Basic ${ Buffer . from ( `${ username } :${ password } ` ) . toString (
20
+ 'base64'
21
+ ) } `
22
+ } else {
23
+ console . warn ( `The haystack URL does not contain authentication credentials` )
24
+ }
8
25
}
9
26
10
27
/**
You can’t perform that action at this time.
0 commit comments