Skip to content

Commit

Permalink
Support flags from local storage as well as URL
Browse files Browse the repository at this point in the history
  • Loading branch information
microbit-matt-hillsdon committed May 28, 2024
1 parent 37da34f commit 387c439
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/flags.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,14 @@ type Flags = Record<Flag, boolean>;
// 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("*")
Expand Down

0 comments on commit 387c439

Please sign in to comment.