mirror of
https://github.com/ankitects/anki.git
synced 2025-11-06 12:47:11 -05:00
Replace custom UUID function with crypto.randomUUID
This commit is contained in:
parent
d11b74fd38
commit
77412ac2aa
2 changed files with 1 additions and 18 deletions
|
|
@ -31,7 +31,6 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import { randomUUID } from "@tslib/uuid";
|
|
||||||
import { onDestroy } from "svelte";
|
import { onDestroy } from "svelte";
|
||||||
import { writable } from "svelte/store";
|
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";
|
$: empty = title === "MathJax";
|
||||||
$: encoded = encodeURIComponent(converted);
|
$: encoded = encodeURIComponent(converted);
|
||||||
|
|
||||||
const uuid = randomUUID();
|
const uuid = crypto.randomUUID();
|
||||||
const imageHeight = writable(0);
|
const imageHeight = writable(0);
|
||||||
imageToHeightMap.set(uuid, imageHeight);
|
imageToHeightMap.set(uuid, imageHeight);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -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));
|
|
||||||
}
|
|
||||||
Loading…
Reference in a new issue