From 2fbea1c0cefb0b124680ec451b2bd212f025ba39 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sat, 21 Mar 2026 11:19:27 +0000 Subject: [PATCH 1/3] Initial plan From 7e03e259b1fa635f1b8ff028efdfab202850c84c Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sat, 21 Mar 2026 11:22:25 +0000 Subject: [PATCH 2/3] Fix #175: strip trailing slash from endpoint to prevent double slashes in URIs Co-authored-by: aviadhahami <7353632+aviadhahami@users.noreply.github.com> Agent-Logs-Url: https://github.com/nodevault/node-vault/sessions/18acbdc1-2e5a-4a10-8209-9c26eefda931 --- src/index.js | 2 ++ test/unit.js | 26 ++++++++++++++++++++++++++ 2 files changed, 28 insertions(+) diff --git a/src/index.js b/src/index.js index 923b7ba..4b17803 100644 --- a/src/index.js +++ b/src/index.js @@ -198,6 +198,8 @@ module.exports = (config = {}) => { client.namespace = config.namespace || process.env.VAULT_NAMESPACE; client.kubernetesPath = config.kubernetesPath || 'kubernetes'; + client.endpoint = client.endpoint.replace(/\/$/, ''); + const requestSchema = { type: 'object', properties: { diff --git a/test/unit.js b/test/unit.js index e214419..31bd9d8 100644 --- a/test/unit.js +++ b/test/unit.js @@ -87,6 +87,32 @@ describe('node-vault', () => { }); }); + describe('client initialization', () => { + it('should not trim endpoint if no trailing slash', () => { + const defaultsStub = sinon.stub(); + const vaultConfig = { + endpoint: 'http://localhost:8200', + 'request-promise': { + defaults: defaultsStub, + }, + }; + const vault = index(vaultConfig); + vault.endpoint.should.equal('http://localhost:8200'); + }); + + it('should trim endpoint if trailing slash', () => { + const defaultsStub = sinon.stub(); + const vaultConfig = { + endpoint: 'http://localhost:8200/', + 'request-promise': { + defaults: defaultsStub, + }, + }; + const vault = index(vaultConfig); + vault.endpoint.should.equal('http://localhost:8200'); + }); + }); + describe('client', () => { let request = null; let response = null; From d17c4b87dd7d2ae16b0e1a72102440f40ee83c93 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sat, 21 Mar 2026 12:05:08 +0000 Subject: [PATCH 3/3] Add test verifying request URI has no double slashes with trailing-slash endpoint Co-authored-by: aviadhahami <7353632+aviadhahami@users.noreply.github.com> Agent-Logs-Url: https://github.com/nodevault/node-vault/sessions/909d7cff-651f-47c2-b036-1f413bb6e575 --- test/unit.js | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/test/unit.js b/test/unit.js index 31bd9d8..cc3bb4f 100644 --- a/test/unit.js +++ b/test/unit.js @@ -111,6 +111,38 @@ describe('node-vault', () => { const vault = index(vaultConfig); vault.endpoint.should.equal('http://localhost:8200'); }); + + it('should not produce double slashes in request URI when endpoint has trailing slash', (done) => { + const request = sinon.stub(); + const response = sinon.stub(); + response.statusCode = 200; + request.returns({ + then(fn) { + return fn(response); + }, + catch(fn) { + return fn(); + }, + }); + + const vault = index({ + endpoint: 'http://localhost:8200/', + token: '123', + 'request-promise': { + defaults: () => request, + }, + }); + + vault.read('secret/hello') + .then(() => { + request.should.have.calledOnce(); + const uri = request.firstCall.args[0].uri; + uri.should.equal('http://localhost:8200/v1/secret/hello'); + uri.should.not.contain('//v1'); + done(); + }) + .catch(done); + }); }); describe('client', () => {