From afc792f55472452586ea1da06dab1be59ca3e6b3 Mon Sep 17 00:00:00 2001 From: IJustDev Date: Sat, 26 Dec 2020 18:34:52 +0100 Subject: [PATCH] feat: base url for Gitea instances Refs: #21 --- package.json | 10 ++++++++++ src/config.ts | 17 +++++++++++++++-- 2 files changed, 25 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 6904590..aeeac7a 100644 --- a/package.json +++ b/package.json @@ -82,6 +82,16 @@ "description": "The remote gitea instance's url. Should not end with a slash.", "pattern": "^(https|http)://" }, + "gitea.baseURL": { + "scope": "resource", + "type": "string", + "default": "", + "examples": [ + "/gitea" + ], + "description": "The base url of the Gitea instance.", + "pattern": "" + }, "gitea.owner": { "scope": "resource", "type": "string", diff --git a/src/config.ts b/src/config.ts index 03ea521..0bd5792 100644 --- a/src/config.ts +++ b/src/config.ts @@ -6,6 +6,7 @@ interface ConfigStorage { owner: string; repo: string; sslVerify: boolean; + baseURL: string; } export interface ConfigTypes extends ConfigStorage { @@ -51,6 +52,14 @@ export class Config implements ConfigTypes { return this.loadConfigValue('instanceURL', 'string'); } + public get baseURL(): string { + return this.loadConfigValue('baseURL', 'string'); + } + + public set baseURL(value) { + this.storage.update('baseURL', 'string'); + } + public get owner() { return this.loadConfigValue('owner', 'string'); } @@ -67,8 +76,12 @@ export class Config implements ConfigTypes { this.storage.update('repo', value); } - public get repoApiUrl() { - return this.instanceURL.replace(/\/$/, "") + '/api/v1/repos/' + this.owner + '/' + this.repo + '/issues'; + public get repoApiUrl(): string { + return this.instanceURL.replace(/\/$/, "") + + this.baseURL.replace(/\/$/, "") + + '/api/v1/repos/' + + this.owner + + '/' + this.repo + '/issues'; } public set sslVerify(value) {