Skip to content

Commit

Permalink
refactor: use valibot to convert Proxy object into vanilla object
Browse files Browse the repository at this point in the history
  • Loading branch information
ninoseki committed Jul 28, 2024
1 parent 541b172 commit d7c1c55
Showing 1 changed file with 3 additions and 15 deletions.
18 changes: 3 additions & 15 deletions src/storage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,19 +15,7 @@ export async function getOptions(): Promise<OptionsType> {
}

export async function setOptions(options: OptionsType): Promise<void> {
await chrome.storage.sync.set({
options: {
debug: options.debug,
strict: options.strict,
punycode: options.punycode,
refang: options.refang,
href: options.href,
disabledSearcherNames: options.disabledSearcherNames.map((n) => n),
disabledScannerNames: options.disabledScannerNames.map((n) => n),
hybridAnalysisAPIKey: options.hybridAnalysisAPIKey,
urlscanAPIKey: options.urlscanAPIKey,
urlscanVisibility: options.urlscanVisibility,
virusTotalAPIKey: options.virusTotalAPIKey,
},
});
// NOTE: use valibot to convert Proxy object into vanilla JS/TS object
const parsed = v.parse(OptionsSchema, options);
await chrome.storage.sync.set({ options: parsed });
}

0 comments on commit d7c1c55

Please sign in to comment.