From 387c4393f21c263c13d7d714063cc7aff177c135 Mon Sep 17 00:00:00 2001 From: Matt Hillsdon Date: Tue, 28 May 2024 14:54:01 +0100 Subject: [PATCH] Support flags from local storage as well as URL --- src/flags.ts | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/flags.ts b/src/flags.ts index 677118bed..1884b248f 100644 --- a/src/flags.ts +++ b/src/flags.ts @@ -67,6 +67,14 @@ type Flags = Record; // Exposed for testing. export const flagsForParams = (stage: Stage, params: URLSearchParams) => { const enableFlags = new Set(params.getAll("flag")); + try { + localStorage + .getItem("flags") + ?.split(",") + ?.forEach((f) => enableFlags.add(f.trim())); + } catch (e) { + // Ignore if there are local storage security issues + } const allFlagsDefault = enableFlags.has("none") ? false : enableFlags.has("*")