Replace custom UUID function with crypto.randomUUID (#4384)

This commit is contained in:
Lee Doughty 2025-10-13 07:37:30 +01:00 committed by GitHub
parent ab2fe98c54
commit 321e23acb2
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 1 additions and 18 deletions

View file

@ -31,7 +31,6 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
</script>
<script lang="ts">
import { randomUUID } from "@tslib/uuid";
import { onDestroy } from "svelte";
import { writable } from "svelte/store";
@ -66,7 +65,7 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
$: empty = title === "MathJax";
$: encoded = encodeURIComponent(converted);
const uuid = randomUUID();
const uuid = crypto.randomUUID();
const imageHeight = writable(0);
imageToHeightMap.set(uuid, imageHeight);

View file

@ -1,16 +0,0 @@
// Copyright: Ankitects Pty Ltd and contributors
// License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
/**
* TODO replace with crypto.randomUUID
*/
export function randomUUID(): string {
const value = `${1e7}-${1e3}-${4e3}-${8e3}-${1e11}`;
return value.replace(/[018]/g, (character: string): string =>
(
Number(character)
^ (crypto.getRandomValues(new Uint8Array(1))[0]
& (15 >> (Number(character) / 4)))
).toString(16));
}