mirror of
https://github.com/kingomarnajjar/flex-template-web.git
synced 2026-07-28 12:43:11 +10:00
Allow canonicalURL helper to return path only
This commit is contained in:
parent
c07b1a7f2c
commit
c7c1b918cd
1 changed files with 3 additions and 3 deletions
|
|
@ -99,7 +99,7 @@ export const findRouteByRouteName = (nameToFind, routes) => {
|
|||
* @return {String} Canonical URL of the given location
|
||||
*
|
||||
*/
|
||||
export const canonicalRoutePath = (routes, location) => {
|
||||
export const canonicalRoutePath = (routes, location, pathOnly = false) => {
|
||||
const { pathname, search, hash } = location;
|
||||
|
||||
const matches = matchPathname(pathname, routes);
|
||||
|
|
@ -116,8 +116,8 @@ export const canonicalRoutePath = (routes, location) => {
|
|||
throw new Error('Expected ListingPage route to have 4 parts');
|
||||
}
|
||||
const canonicalListingPathname = `/${parts[1]}/${parts[3]}`;
|
||||
return `${canonicalListingPathname}${search}${hash}`;
|
||||
return pathOnly ? canonicalListingPathname : `${canonicalListingPathname}${search}${hash}`;
|
||||
}
|
||||
|
||||
return `${pathname}${search}${hash}`;
|
||||
return pathOnly ? pathname : `${pathname}${search}${hash}`;
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue