Describe the bug
We do URL rewrite on the AEM Dispatcher level, so our URLs and extension-less, e.g. /home. We recently noticed, that when you navigate to the page containing query param with the dot . - e.g. /home/search?q=some.param.with.dots, the router logic breaks unable to load the correct page model.
Package version1.3.6
To Reproduce
Assuming you have two valid AEM pages at /home and /home/search and home links out to /home/search
Go to /home
Click on the valid page link with some query params in it containing dots like /home/search?q=some.param.with.dots
See blank page and an invalid model request in the Network tab: /home/search.?q=some.model.json?q=some.model
Expected behavior
Page model should be loaded at /home/search.model.json regardless of what is in query params as long as it complies with URL spec.
Additional context
We believe that the problem is in the getModelPath method of the ModelRouter component:
export function getModelPath(url?: string | null): string {
const localUrl = url || window.location.pathname;
// The default value model path comes as the the content path
let endPosition = localUrl.indexOf('.');
if (endPosition < 0) {
// If the path is missing extension and has query params instead eg. http://zyx/abc?test=test
const queryPosition = localUrl.indexOf('?');
endPosition = (queryPosition < 0) ? localUrl.length : queryPosition;
}
return localUrl.substr(0, endPosition);
}
I think the method is better to rewrite to first strip-off all the query params, and then extract page path without .html bit explicitly, rather than rely on dots only.
Describe the bug We do URL rewrite on the AEM Dispatcher level, so our URLs and extension-less, e.g.
/home
. We recently noticed, that when you navigate to the page containing query param with the dot.
- e.g./home/search?q=some.param.with.dots
, the router logic breaks unable to load the correct page model.Package version
1.3.6
To Reproduce Assuming you have two valid AEM pages at
/home
and/home/search
andhome
links out to/home/search
/home
/home/search?q=some.param.with.dots
/home/search.?q=some.model.json?q=some.model
Expected behavior Page model should be loaded at
/home/search.model.json
regardless of what is in query params as long as it complies with URL spec.Additional context We believe that the problem is in the getModelPath method of the
ModelRouter
component:I think the method is better to rewrite to first strip-off all the query params, and then extract page path without
.html
bit explicitly, rather than rely on dots only.