fix: remove trailing slash from url if needed

This commit is contained in:
Anselm Stordeur
2018-12-04 18:15:39 +01:00
parent 8541b00dbb
commit eb7c334bb8
2 changed files with 4 additions and 1 deletions

View File

@@ -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';

View File

@@ -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 = {