Skip to content

Commit

Permalink
fix: #64 Error: getaddrinfo ENOTFOUND" on upgrade to 0.12.0
Browse files Browse the repository at this point in the history
  • Loading branch information
gioboa committed Jan 15, 2019
1 parent d143035 commit df0c8d1
Showing 1 changed file with 12 additions and 9 deletions.
21 changes: 12 additions & 9 deletions src/http/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

1 comment on commit df0c8d1

@knicefire
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Have you figured out what caused the error?
May it be caused the port being null?
Because in parsedUrl it is parsed as null and in your implementation it defaults to undefined

Please sign in to comment.