Skip to content

Commit

Permalink
fix(server): Re-send also multiple search-params in URL
Browse files Browse the repository at this point in the history
Until now, if there were multiple "?" in the URL and thus multiple search-params, only the first were taken.
With this commit, all search params are resent to the remote server
  • Loading branch information
jmacura committed Feb 5, 2024
1 parent 93e8b1e commit 50c4536
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions projects/hslayers-server/src/proxy.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ createServer((req, res) => {
res.write(`${getIP()}:${port}`);
res.end();
} else {
//tinyurl requests are encoded on client + dont work well with encodeUrlPathAndParams
if (req.url.includes('http://tinyurl.com/api-create.php') || req.url.includes()) {
//tinyurl requests are encoded on client
if (req.url.includes('http://tinyurl.com/api-create.php')) {
cors_proxy.emit('request', req, res);
return
}
Expand Down Expand Up @@ -125,12 +125,12 @@ export const splitUrlAtTld = (url) => {
* but leaves the host name untouched
* @param {string} url URL
* @returns partially encoded URL
* NOTE: doesnt really seem to work for urls where one of the params is another url
*/
export const encodeUrlPathAndParams = (url) => {
const [base, tld, pathAndQueryParams] = splitUrlAtTld(url);
const encodedPath = pathAndQueryParams.split('?')[0].split('/').map(segment => encodeURIComponent(segment))
const params = parseQuerystring(pathAndQueryParams.split('?')[1]);
const encodedPath = pathAndQueryParams.split('?')[0].split('/').map(segment => encodeURIComponent(segment));
const [, ...queryParams] = pathAndQueryParams.split('?');
const params = parseQuerystring(queryParams);
return base +
'.' +
tld +
Expand Down

0 comments on commit 50c4536

Please sign in to comment.