File tree Expand file tree Collapse file tree 2 files changed +14
-2
lines changed
Expand file tree Collapse file tree 2 files changed +14
-2
lines changed Original file line number Diff line number Diff line change @@ -89,8 +89,12 @@ function filterHeaders (headers, filter) {
8989}
9090
9191function buildURL ( source = '' , reqBase ) {
92- // issue ref: https://github.com/fastify/fast-proxy/issues/42
93- const cleanSource = source . replace ( / \/ + / g, '/' )
92+ // issue ref: https://github.com/fastify/fast-proxy/issues/42, https://github.com/fastify/fast-proxy/issues/76
93+ let i = 0
94+ while ( source [ i ] === '/' ) {
95+ i ++
96+ }
97+ const cleanSource = i > 0 ? '/' + source . substring ( i ) : source
9498
9599 return new URL ( cleanSource , reqBase )
96100}
Original file line number Diff line number Diff line change @@ -27,6 +27,14 @@ describe('buildURL', () => {
2727 expect ( url . href ) . to . equal ( 'http://localhost/hi' )
2828 } )
2929
30+ it ( 'should not strip double slashes from query parameters' , function ( ) {
31+ const url = buildURL ( '/hi?bye=https%3A//example.com' , 'http://localhost' )
32+
33+ expect ( url . origin ) . to . equal ( 'http://localhost' )
34+ expect ( url . pathname ) . to . equal ( '/hi' )
35+ expect ( url . href ) . to . equal ( 'http://localhost/hi?bye=https%3A//example.com' )
36+ } )
37+
3038 it ( 'should produce valid URL (1 param)' , function ( ) {
3139 const url = buildURL ( 'http://localhost/hi' )
3240
You can’t perform that action at this time.
0 commit comments