diff options
| author | Adam <[email protected]> | 2026-02-11 19:05:15 -0600 |
|---|---|---|
| committer | GitHub <[email protected]> | 2026-02-12 01:05:15 +0000 |
| commit | 81ca2df6ad57085b895caafc386e4ac4ab9098a6 (patch) | |
| tree | 3a78f5125aff9ebf84e98275a72f5fdd13d930ff /packages/app/src/utils/perf.ts | |
| parent | aea68c386a4f64cf718c3eeee9dffec8409ee6b0 (diff) | |
| download | opencode-81ca2df6ad57085b895caafc386e4ac4ab9098a6.tar.gz opencode-81ca2df6ad57085b895caafc386e4ac4ab9098a6.zip | |
fix(app): guard randomUUID in insecure browser contexts (#13237)
Co-authored-by: Selim <[email protected]>
Diffstat (limited to 'packages/app/src/utils/perf.ts')
| -rw-r--r-- | packages/app/src/utils/perf.ts | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/packages/app/src/utils/perf.ts b/packages/app/src/utils/perf.ts index 0ecbc33ff..105d02a82 100644 --- a/packages/app/src/utils/perf.ts +++ b/packages/app/src/utils/perf.ts @@ -1,3 +1,5 @@ +import { uuid } from "@/utils/uuid" + type Nav = { id: string dir?: string @@ -16,8 +18,6 @@ const key = (dir: string | undefined, to: string) => `${dir ?? ""}:${to}` const now = () => performance.now() -const uid = () => crypto.randomUUID?.() ?? Math.random().toString(16).slice(2) - const navs = new Map<string, Nav>() const pending = new Map<string, string>() const active = new Map<string, string>() @@ -94,7 +94,7 @@ function ensure(id: string, data: Omit<Nav, "marks" | "logged" | "timer">) { export function navStart(input: { dir?: string; from?: string; to: string; trigger?: string }) { if (!dev) return - const id = uid() + const id = uuid() const start = now() const nav = ensure(id, { ...input, id, start }) nav.marks["navigate:start"] = start @@ -109,7 +109,7 @@ export function navParams(input: { dir?: string; from?: string; to: string }) { const k = key(input.dir, input.to) const pendingId = pending.get(k) if (pendingId) pending.delete(k) - const id = pendingId ?? uid() + const id = pendingId ?? uuid() const start = now() const nav = ensure(id, { ...input, id, start, trigger: pendingId ? "key" : "route" }) |
