File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -48,6 +48,8 @@ module.exports = (config = {}) => {
4848 : undefined ;
4949
5050 const instance = axios . create ( {
51+ // Accept all HTTP status codes (equivalent to request's simple: false)
52+ // so that vault response handling logic can process non-2xx responses.
5153 validateStatus : ( ) => true ,
5254 ...( httpsAgent ? { httpsAgent } : { } ) ,
5355 ...( rpDefaults . timeout ? { timeout : rpDefaults . timeout } : { } ) ,
@@ -64,13 +66,21 @@ module.exports = (config = {}) => {
6466 axiosOptions . data = options . json ;
6567 }
6668
67- return instance ( axiosOptions ) . then ( ( response ) => ( {
68- statusCode : response . status ,
69- body : response . data ,
70- request : {
71- path : new URL ( options . uri ) . pathname ,
72- } ,
73- } ) ) ;
69+ return instance ( axiosOptions ) . then ( ( response ) => {
70+ let requestPath ;
71+ try {
72+ requestPath = new URL ( options . uri ) . pathname ;
73+ } catch ( _e ) {
74+ requestPath = options . uri ;
75+ }
76+ return {
77+ statusCode : response . status ,
78+ body : response . data ,
79+ request : {
80+ path : requestPath ,
81+ } ,
82+ } ;
83+ } ) ;
7484 } ;
7585 } ) ( ) ;
7686 const client = { } ;
You can’t perform that action at this time.
0 commit comments