Skip to content

Commit d143035

Browse files
authored
Merge pull request #63 from gioboa/fix/#62
fix: managed subfolder in baseUrl setting #62
2 parents 618d3f7 + 6757201 commit d143035

File tree

2 files changed

+13
-9
lines changed

2 files changed

+13
-9
lines changed

src/commands/setup-credentials.ts

+10-8
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,16 @@ export default async function setupCredentials(): Promise<void> {
1515
}
1616

1717
// store settings
18-
setConfigurationByKey(
19-
CONFIG.BASE_URL,
20-
await vscode.window.showInputBox({
21-
ignoreFocusOut: true,
22-
password: false,
23-
placeHolder: 'Your Jira url'
24-
})
25-
);
18+
let newBaseUrl = await vscode.window.showInputBox({
19+
ignoreFocusOut: true,
20+
password: false,
21+
placeHolder: 'Your Jira url'
22+
});
23+
// remove / at the end
24+
if (!!newBaseUrl && newBaseUrl.substring(newBaseUrl.length - 1) === '/') {
25+
newBaseUrl = newBaseUrl.substring(0, newBaseUrl.length - 1);
26+
}
27+
setConfigurationByKey(CONFIG.BASE_URL, newBaseUrl);
2628

2729
setConfigurationByKey(
2830
CONFIG.USERNAME,

src/http/api.ts

+3-1
Original file line numberDiff line numberDiff line change
@@ -35,10 +35,12 @@ export class Jira implements IJira {
3535

3636
if (this.baseUrl && getGlobalStateConfiguration()) {
3737
const parsedUrl = url.parse(this.baseUrl);
38+
// host from parsedUrl.href because the base url can have subfolder
39+
const host = parsedUrl.href.replace(parsedUrl.protocol + '//', '');
3840
const [username, password] = getGlobalStateConfiguration().split(CREDENTIALS_SEPARATOR);
3941

4042
this.jiraInstance = new jiraClient({
41-
host: parsedUrl.host,
43+
host: host,
4244
port: parsedUrl.port,
4345
protocol: parsedUrl.protocol,
4446
basic_auth: { username, password }

0 commit comments

Comments
 (0)