File tree Expand file tree Collapse file tree 1 file changed +17
-0
lines changed Expand file tree Collapse file tree 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 {
55 this . app = app
66 this . haystackURL = haystackURL
77 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+ }
825 }
926
1027 /**
You can’t perform that action at this time.
0 commit comments