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

fix: fix playground share link in production #1660

Merged
merged 2 commits into from
Nov 22, 2024
Merged
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
5 changes: 2 additions & 3 deletions playground/nextjs-app-router/lib/url-params.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,21 +33,20 @@ const URL_PARAM_MAPPING: Partial<Record<OnchainKitComponent, string[]>> = {

export function getShareableUrl(activeComponent?: OnchainKitComponent) {
if (!activeComponent) {
return window.location.origin;
return `${window.location.origin}${window.location.pathname}`;
}

const relevantParams = getComponentQueryParams(activeComponent);
const params = new URLSearchParams();

for (const param of [...relevantParams, ...commonOptions]) {
const value = localStorage.getItem(getStorageKey(param));
// Only include the param if it's not the default value
if (value && value !== defaultState[param as keyof typeof defaultState]) {
params.set(param, value);
}
}

return `${window.location.origin}?${params.toString()}`;
return `${window.location.origin}${window.location.pathname}?${params.toString()}`;
}

export function getComponentQueryParams(component: OnchainKitComponent) {
Expand Down