Skip to content

Commit

Permalink
fixes cache key when using props (#373)
Browse files Browse the repository at this point in the history
* fixes cache key when using props

* update deco
  • Loading branch information
hugo-ccabral authored Feb 6, 2024
1 parent 9d64465 commit 067c0f5
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 14 deletions.
2 changes: 1 addition & 1 deletion deno.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"std/": "https://deno.land/[email protected]/",
"partytown/": "https://deno.land/x/[email protected]/",
"deco-sites/std/": "https://denopkg.com/deco-sites/[email protected]/",
"deco/": "https://denopkg.com/deco-cx/[email protected].15/"
"deco/": "https://denopkg.com/deco-cx/[email protected].18/"
},
"lock": false,
"tasks": {
Expand Down
5 changes: 3 additions & 2 deletions vtex/loaders/intelligentSearch/productDetailsPage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -149,10 +149,11 @@ export const cacheKey = (props: Props, req: Request, ctx: AppContext) => {
const { token } = getSegmentFromBag(ctx);
const url = new URL(req.url);

const params = new URLSearchParams();
const params = new URLSearchParams([
["slug", props.slug],
]);
params.set("skuId", url.searchParams.get("skuId") ?? "");
params.set("segment", token);
params.set("slug", props.slug);

url.search = params.toString();

Expand Down
20 changes: 9 additions & 11 deletions vtex/loaders/intelligentSearch/productListingPage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -431,7 +431,15 @@ export const cacheKey = (props: Props, req: Request, ctx: AppContext) => {
return null;
}

const params = new URLSearchParams();
const params = new URLSearchParams([
["query", props.query ?? ""],
["count", props.count.toString()],
["page", (props.page ?? 1).toString()],
["sort", props.sort ?? ""],
["fuzzy", props.fuzzy ?? ""],
["hideUnavailableItems", props.hideUnavailableItems?.toString() ?? ""],
["pageOffset", (props.pageOffset ?? 1).toString()],
]);

url.searchParams.forEach((value, key) => {
if (!ALLOWED_PARAMS.has(key.toLowerCase()) && !key.startsWith("filter.")) {
Expand All @@ -443,16 +451,6 @@ export const cacheKey = (props: Props, req: Request, ctx: AppContext) => {

params.sort();
params.set("segment", token);
params.set("query", props.query ?? "");
params.set("count", props.count.toString());
params.set("page", (props.page ?? 1).toString());
params.set("sort", props.sort ?? "");
params.set("fuzzy", props.fuzzy ?? "");
params.set(
"hideUnavailableItems",
props.hideUnavailableItems?.toString() ?? "",
);
params.set("pageOffset", (props.pageOffset ?? 1).toString());

url.search = params.toString();

Expand Down

0 comments on commit 067c0f5

Please sign in to comment.