Skip to content

Commit

Permalink
Fix bugs with new create response decoding and update post-creation w…
Browse files Browse the repository at this point in the history
…orkflow to match
  • Loading branch information
daniellrgn committed Feb 3, 2025
1 parent 836ac08 commit 6cfbbfe
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
6 changes: 4 additions & 2 deletions src/lib/utils/managementClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,11 @@ export class SHLClient {
},
body: JSON.stringify(config)
});
const shlink = await res.json();
const shlink = await res.text();
const payload = shlink.split('/');
const shl: SHLAdminParams = JSON.parse(base64url.decode(payload[payload.length - 1]).toString());
const decodedPayload = base64url.decode(payload[payload.length - 1]);
const asString = new TextDecoder('utf-8').decode(decodedPayload);
const shl: SHLAdminParams = JSON.parse(asString);
return shl;
}

Expand Down
4 changes: 3 additions & 1 deletion src/routes/(app)/create/+page.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,10 @@
async function newShlFromShc(details: SHLSubmitEvent): Promise<SHLAdminParams> {
shlStatus = "Creating SHL";
let shlCreated = await shlClient.createShl({exp: details.exp, passcode: details.passcode, label: details.label });
$shlStore = await shlClient.getUserShls();
let fullShlCreated = $shlStore.filter((s) => s.id === shlCreated.id)[0];
shlStatus = "Adding IPS";
shlCreated = await addFiles(shlCreated, details.shcs);
shlCreated = await addFiles(fullShlCreated, details.shcs);
return shlCreated;
}
Expand Down

0 comments on commit 6cfbbfe

Please sign in to comment.