Skip to content

Commit 14437f3

Browse files
committed
feat: slash
1 parent aec5c87 commit 14437f3

File tree

3 files changed

+8
-5
lines changed

3 files changed

+8
-5
lines changed

src/keys/get-management-token.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ const getTokenFromOneTimeToken = async (
5757
log(`Requesting CMA Token with given App Token`)
5858

5959
const requestor = makeRequest(
60-
`/spaces/${spaceId}/environments/${environmentId}/app_installations/${appInstallationId}/access_tokens`,
60+
`spaces/${spaceId}/environments/${environmentId}/app_installations/${appInstallationId}/access_tokens`,
6161
{
6262
method: 'POST',
6363
headers: {

src/utils/http.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,10 @@ export const makeRequest = (
2121
fetchOptions: FetchOptions,
2222
): Requestor => {
2323
return async (): Promise<Response> => {
24-
const response = await fetch(`${fetchOptions.prefixUrl}${url}`, options)
24+
const prefixWithSlash = fetchOptions.prefixUrl.endsWith('/')
25+
? fetchOptions.prefixUrl
26+
: `${fetchOptions.prefixUrl}/`
27+
const response = await fetch(`${prefixWithSlash}${url}`, options)
2528
if (!response.ok) {
2629
throw new HttpError(response)
2730
}

test/utils.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ export const cleanOldKeys = async () => {
1010
const appDefinitionId = process.env.APP_ID
1111

1212
const requestor = makeRequest(
13-
`/organizations/${organizationId}/app_definitions/${appDefinitionId}/keys`,
13+
`organizations/${organizationId}/app_definitions/${appDefinitionId}/keys`,
1414
{
1515
method: 'GET',
1616
headers: {
@@ -27,7 +27,7 @@ export const cleanOldKeys = async () => {
2727

2828
const deleteKeysRequests = fingerprints.map((fingerprint: string) => {
2929
const requestor = makeRequest(
30-
`/organizations/${organizationId}/app_definitions/${appDefinitionId}/keys/${fingerprint}`,
30+
`organizations/${organizationId}/app_definitions/${appDefinitionId}/keys/${fingerprint}`,
3131
{
3232
method: 'DELETE',
3333
headers: {
@@ -48,7 +48,7 @@ export const setPublicKey = async (publicKey: Buffer) => {
4848
const keyId = base64url(crypto.createHash('sha256').update(publicKey).digest())
4949

5050
const requestor = makeRequest(
51-
`/organizations/${organizationId}/app_definitions/${appDefinitionId}/keys`,
51+
`organizations/${organizationId}/app_definitions/${appDefinitionId}/keys`,
5252
{
5353
method: 'POST',
5454
headers: {

0 commit comments

Comments
 (0)