catalog-backend/chore: replace regexp with trimEnd

Signed-off-by: Johan Haals <johan.haals@gmail.com>
This commit is contained in:
Johan Haals
2021-10-06 16:15:20 +02:00
parent 09d8329052
commit 7b78dd17e6
2 changed files with 8 additions and 2 deletions
+5
View File
@@ -0,0 +1,5 @@
---
'@backstage/plugin-catalog-backend': patch
---
Replace slash stripping regexp with trimEnd to remove CodeQL warning
@@ -15,6 +15,7 @@
*/
import { Config } from '@backstage/config';
import { trimEnd } from 'lodash';
/**
* The configuration parameters for a single GitHub API provider.
@@ -52,12 +53,12 @@ export function readGithubConfig(config: Config): ProviderConfig[] {
// First read all the explicit providers
for (const providerConfig of providerConfigs) {
const target = providerConfig.getString('target').replace(/\/+$/, '');
const target = trimEnd(providerConfig.getString('target'), '/');
let apiBaseUrl = providerConfig.getOptionalString('apiBaseUrl');
const token = providerConfig.getOptionalString('token');
if (apiBaseUrl) {
apiBaseUrl = apiBaseUrl.replace(/\/+$/, '');
apiBaseUrl = trimEnd(apiBaseUrl, '/');
} else if (target === 'https://github.com') {
apiBaseUrl = 'https://api.github.com';
}