Skip to content

Commit a2744ea

Browse files
feat(www): shorter repl shareables (#6088)
Co-authored-by: Lukas Taegert-Atkinson <[email protected]>
1 parent 298609e commit a2744ea

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

docs/repl/helpers/query.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@ export async function useUpdateStoresFromQuery() {
1515
const query = Object.fromEntries(urlParameters as unknown as Iterable<[string, string]>);
1616
try {
1717
if (query.shareable) {
18-
const json = decodeURIComponent(atob(query.shareable));
18+
const rawJson = atob(query.shareable.replace(/_/g, '/').replace(/-/g, '+'));
19+
const json = rawJson.startsWith('%') ? decodeURIComponent(rawJson) : rawJson;
1920
const {
2021
modules: queryModules,
2122
options: queryOptions,
@@ -104,7 +105,7 @@ export function useSyncQueryWithStores() {
104105
options
105106
});
106107

107-
parameters.shareable = btoa(encodeURIComponent(json));
108+
parameters.shareable = btoa(json).replace(/\//g, '_').replace(/\+/g, '-');
108109
const queryString = Object.keys(parameters)
109110
.map(key => `${key}=${parameters[key]}`)
110111
.join('&');

0 commit comments

Comments
 (0)