From d1ee797e54c0582277ff8f629887f02b01cec5d4 Mon Sep 17 00:00:00 2001
From: Rhys Arkins <rhys@arkins.net>
Date: Mon, 20 Aug 2018 12:53:57 +0200
Subject: [PATCH] fix: add trailing / to endpoint

Closes #2363
---
 lib/util/endpoints.js                                       | 1 +
 .../vsts/__snapshots__/vsts-got-wrapper.spec.js.snap        | 6 +++---
 test/util/__snapshots__/endpoints.spec.js.snap              | 2 +-
 3 files changed, 5 insertions(+), 4 deletions(-)

diff --git a/lib/util/endpoints.js b/lib/util/endpoints.js
index b70c731374..bdfe69488e 100644
--- a/lib/util/endpoints.js
+++ b/lib/util/endpoints.js
@@ -28,6 +28,7 @@ function update(params) {
       `Failed to configure platform '${platform}': no endpoint defined`
     );
   }
+  config.endpoint = endpoint.replace(/[^/]$/, '$&/');
   let { host } = config;
   // extract host from endpoint
   host = host || (endpoint && URL.parse(endpoint).host);
diff --git a/test/platform/vsts/__snapshots__/vsts-got-wrapper.spec.js.snap b/test/platform/vsts/__snapshots__/vsts-got-wrapper.spec.js.snap
index 6e84ab82bc..30c551641f 100644
--- a/test/platform/vsts/__snapshots__/vsts-got-wrapper.spec.js.snap
+++ b/test/platform/vsts/__snapshots__/vsts-got-wrapper.spec.js.snap
@@ -25,12 +25,12 @@ WebApi {
       "userAgent": "vsts-node-api",
     },
   },
-  "serverUrl": "myEndpoint",
+  "serverUrl": "myEndpoint/",
   "vsoClient": VsoClient {
     "_initializationPromise": Promise {},
     "_locationsByAreaPromises": Object {},
-    "basePath": "myEndpoint",
-    "baseUrl": "myEndpoint",
+    "basePath": "myEndpoint/",
+    "baseUrl": "myEndpoint/",
     "restClient": RestClient {
       "client": HttpClient {
         "_certConfig": undefined,
diff --git a/test/util/__snapshots__/endpoints.spec.js.snap b/test/util/__snapshots__/endpoints.spec.js.snap
index 96c7b38024..c9e912f388 100644
--- a/test/util/__snapshots__/endpoints.spec.js.snap
+++ b/test/util/__snapshots__/endpoints.spec.js.snap
@@ -2,7 +2,7 @@
 
 exports[`util/endpoints find() allows overrides 1`] = `
 Object {
-  "endpoint": "endpoint",
+  "endpoint": "endpoint/",
   "name": "GitHub",
   "other": "data",
   "platform": "github",
-- 
GitLab