From eb7c334bb8878cffd96cd9d52b5b99e2338e3a65 Mon Sep 17 00:00:00 2001 From: Anselm Stordeur Date: Tue, 4 Dec 2018 18:15:39 +0100 Subject: [PATCH] fix: remove trailing slash from url if needed --- src/cli.ts | 2 +- src/client.ts | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/src/cli.ts b/src/cli.ts index c10c672f..11228d6c 100755 --- a/src/cli.ts +++ b/src/cli.ts @@ -16,7 +16,7 @@ import {Logger} from '@openstapps/logger'; import * as commander from 'commander'; import {readFileSync} from 'fs'; import {join} from 'path'; -import { URL } from 'url'; +import {URL} from 'url'; import {copy} from './copy'; import {HttpClient} from './httpClient'; diff --git a/src/client.ts b/src/client.ts index 0222e286..479c2fd2 100644 --- a/src/client.ts +++ b/src/client.ts @@ -98,6 +98,9 @@ export class Client { * TODO: remove headers/version */ constructor(protected httpClient: HttpClientInterface, protected url: string, protected version?: string) { + // cut trailing slash if needed + this.url = this.url.replace(/\/$/, ''); + if (typeof version === 'string') { // set header to tell proxy to select the correct backend this.headers = {