dvonlehman / express-request-proxy

Advanced streaming http request proxy middleware for Express with support for custom routes, caching, and response transforms.
96 stars 38 forks source link

Handle original query for URLs without ? character #40

Open chris-jamieson opened 5 years ago

chris-jamieson commented 5 years ago

When using originalQuery: true option, if the URL does not have a ? character, the regex /^.+\?/ causes the entire request URL to be set as the search parameter. This change checks for the presence of a ? character in the string, and sets an empty string as the search parameter if not present.

At present, the query logic does not account for URLs without a ? character.

For example, a request with URL http://example.com/foo with option originalQuery: true would be transformed to https://my-proxy-destination.com/bar?http://example.com/foo, while http://example.com/foo?id=4 would correctly be transformed to `https://my-proxy-destination.com/bar?id=4

The correct behaviour for URLs without a query string (and therefore no ? character) is that no query should be set to the proxy URL.

coveralls commented 5 years ago

Pull Request Test Coverage Report for Build 90


Changes Missing Coverage Covered Lines Changed/Added Lines %
lib/request-options.js 2 3 66.67%
<!-- Total: 2 3 66.67% -->
Totals Coverage Status
Change from base Build 85: -0.4%
Covered Lines: 169
Relevant Lines: 183

💛 - Coveralls