Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Percentage symbol in query string breaks in SSR #400

Merged
merged 2 commits into from
Jul 9, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions packages/sitecore-jss-proxy/src/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,23 @@ describe('rewriteRequestPath', () => {

expect(actual).to.equal(expected);
});

it('should return route prefixed with layout service route and with querystring appended that contains percentage symbol', () => {
const url = '/styleguide?x=%25';
const expected = '/sitecore/layoutsvc/render/jss?item=%2Fstyleguide&sc_apikey={GUID}&x=%25&y=test';
const mockRequest = {
query: {
x: '%',
y: 'test',
},
headers: {
'accept-encoding': 'gzip or whatever',
},
};

const actual = rewriteRequestPath(url, mockRequest, config);
expect(actual).to.equal(expected);
});
});
describe('when a route parsing function is provided', () => {
it('should use the item path and language provided by the function', () => {
Expand Down
4 changes: 2 additions & 2 deletions packages/sitecore-jss-proxy/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { IncomingMessage, ServerResponse } from 'http';
import proxy from 'http-proxy-middleware';
import setCookieParser from 'set-cookie-parser';
import HttpStatus from 'http-status-codes';
import setCookieParser from 'set-cookie-parser';
import zlib from 'zlib'; // node.js standard lib
import { AppRenderer } from './AppRenderer';
import { ProxyConfig } from './ProxyConfig';
Expand Down Expand Up @@ -298,7 +298,7 @@ export function rewriteRequestPath(
const decodedReqPath = decodeURIComponent(reqPath);

// if the request URL contains a path/route that should not be re-written, then just pass it along as-is
if (isUrlIgnored(decodedReqPath, config)) {
if (isUrlIgnored(reqPath, config)) {
// we do not return the decoded URL because we're using it verbatim - should be encoded.
return reqPath;
}
Expand Down