From df0c8d1c7813432fb66122b8d9f287cf61a8976f Mon Sep 17 00:00:00 2001 From: gioboa Date: Tue, 15 Jan 2019 09:26:40 +0100 Subject: [PATCH] fix: #64 Error: getaddrinfo ENOTFOUND" on upgrade to 0.12.0 --- src/http/api.ts | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/src/http/api.ts b/src/http/api.ts index 1f5fc1c..f487a52 100644 --- a/src/http/api.ts +++ b/src/http/api.ts @@ -34,17 +34,20 @@ export class Jira implements IJira { this.baseUrl = getConfigurationByKey(CONFIG.BASE_URL) || ''; if (this.baseUrl && getGlobalStateConfiguration()) { - const parsedUrl = url.parse(this.baseUrl); + // prepare config for jira-connector + let host = this.baseUrl; + const protocol = host.indexOf('https://') >= 0 ? 'https' : 'http'; + host = host.replace('https://', '').replace('http://', ''); + const portPosition = host.indexOf(':'); + const port = portPosition !== -1 ? host.substring(portPosition + 1) : undefined; + if (portPosition !== -1) { + host = host.substring(0, portPosition); + } + // TODO - manage subfolder // host from parsedUrl.href because the base url can have subfolder - const host = parsedUrl.href.replace(parsedUrl.protocol + '//', ''); + // const host = parsedUrl.href.replace(parsedUrl.protocol + '//', ''); const [username, password] = getGlobalStateConfiguration().split(CREDENTIALS_SEPARATOR); - - this.jiraInstance = new jiraClient({ - host: host, - port: parsedUrl.port, - protocol: parsedUrl.protocol, - basic_auth: { username, password } - }); + this.jiraInstance = new jiraClient({ host, port, protocol, basic_auth: { username, password } }); // custom event // solve this issue -> https://github.com/floralvikings/jira-connector/issues/115