Skip to content

Commit

Permalink
discard invalid account IDs but still invalidate valid ones
Browse files Browse the repository at this point in the history
  • Loading branch information
efstajas committed Jul 1, 2024
1 parent 1e88886 commit 2781023
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions src/routes/api/cache/invalidate-account-ids/+server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -98,12 +98,17 @@ export const POST = async ({ request }) => {

assert(Array.isArray(accountIds), 'Invalid account ids');

accountIds.forEach((accountId) => {
assert(/^[0-9]+$/.test(accountId), `Invalid account ID: ${accountId}`);
const validAccountIds: string[] = accountIds.filter((v) => {
if (typeof v === 'string' && /^[0-9]+$/.test(v)) {
return true;
} else {
log('INVALID ACCOUNT ID', { accountId: v });
return false;
}
});

await Promise.all(
accountIds.map((accountId) => {
validAccountIds.map((accountId) => {
const driver = Utils.AccountId.getDriver(accountId);

switch (driver) {
Expand Down

0 comments on commit 2781023

Please sign in to comment.