Skip to content

Commit

Permalink
example: Use location pathname when saving search parameters (livekit…
Browse files Browse the repository at this point in the history
…#178)

If the sample is hosted from a path other than `/`, it would get reset
to the root path. Set the path based on the current location when adding
the search parameters.
  • Loading branch information
bekriebel committed Mar 30, 2022
1 parent 9436039 commit 5124ab8
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion example/sample.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,11 @@ const storedToken = searchParams.get('token') ?? '';

function updateSearchParams(url: string, token: string) {
const params = new URLSearchParams({ url, token });
window.history.replaceState(null, '', `/?${params.toString()}`);
window.history.replaceState(
null,
'',
`${window.location.pathname}?${params.toString()}`,
);
}

// handles actions from the HTML
Expand Down

0 comments on commit 5124ab8

Please sign in to comment.