Skip to content

Commit

Permalink
feat: detect malformed data
Browse files Browse the repository at this point in the history
  • Loading branch information
KnorpelSenf committed Nov 13, 2024
1 parent 7d48ebf commit 5e1295b
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/storage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,9 @@ export function pinVersion(version: string | number): PinnedVersion {
}
function unpack<S>(data?: VersionedState<S>): S | undefined {
if (data === undefined) return undefined;
if (!Array.isArray(data.version)) {
throw new Error("Unknown data format, cannot parse version");
}
const [pluginVersion, dataVersion] = data.version;
if (dataVersion !== version) return undefined;
if (pluginVersion !== PLUGIN_DATA_VERSION) {
Expand Down

0 comments on commit 5e1295b

Please sign in to comment.