File tree Expand file tree Collapse file tree 2 files changed +27
-0
lines changed
Expand file tree Collapse file tree 2 files changed +27
-0
lines changed Original file line number Diff line number Diff line change @@ -71,6 +71,8 @@ module.exports = (config = {}) => {
7171 client . noCustomHTTPVerbs = config . noCustomHTTPVerbs || false ;
7272 client . namespace = config . namespace || process . env . VAULT_NAMESPACE ;
7373
74+ client . endpoint = client . endpoint . replace ( / \/ $ / , '' ) ;
75+
7476 const requestSchema = {
7577 type : 'object' ,
7678 properties : {
Original file line number Diff line number Diff line change @@ -87,6 +87,31 @@ describe('node-vault', () => {
8787 } ) ;
8888 } ) ;
8989
90+ describe ( 'client initialization' , ( ) => {
91+ it ( 'should not trim endpoint if no trailing slash' , ( ) => {
92+ const defaultsStub = sinon . stub ( ) ;
93+ const vaultConfig = {
94+ endpoint : 'http://localhost:8200' ,
95+ 'request-promise' : {
96+ defaults : defaultsStub ,
97+ } ,
98+ } ;
99+ const vault = index ( vaultConfig ) ;
100+ vault . endpoint . should . equal ( 'http://localhost:8200' ) ;
101+ } ) ;
102+
103+ it ( 'should trim endpoint if trailing slash' , ( ) => {
104+ const defaultsStub = sinon . stub ( ) ;
105+ const vaultConfig = {
106+ endpoint : 'http://localhost:8200/' ,
107+ 'request-promise' : {
108+ defaults : defaultsStub ,
109+ } ,
110+ } ;
111+ const vault = index ( vaultConfig ) ;
112+ vault . endpoint . should . equal ( 'http://localhost:8200' ) ;
113+ } ) ;
114+ } ) ;
90115
91116 describe ( 'client' , ( ) => {
92117 let request = null ;
You can’t perform that action at this time.
0 commit comments