mirror of
https://github.com/mollersuite/monofile.git
synced 2024-11-22 05:46:26 -08:00
TODO: fix possible mitm in icon.svelte
split writes "Worst Svelte Component Ever", asked to leave Etcetera
This commit is contained in:
parent
707dbeb559
commit
d7698100d1
26
src/svelte/elem/Icon.svelte
Normal file
26
src/svelte/elem/Icon.svelte
Normal file
|
@ -0,0 +1,26 @@
|
||||||
|
<script context="module">
|
||||||
|
|
||||||
|
let iconCache = new Map()
|
||||||
|
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
export let icon; // like "admin/___"
|
||||||
|
let iconSrc;
|
||||||
|
|
||||||
|
if (iconCache.has(icon)) {
|
||||||
|
iconSrc = iconCache.get(icon)
|
||||||
|
} else {
|
||||||
|
fetch(`/static/assets/icons/${icon}`).then((response) => {
|
||||||
|
if (response.ok) response.text().then(src => {
|
||||||
|
iconCache.set( icon, src )
|
||||||
|
iconSrc = src
|
||||||
|
})
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<div class="iconContainer">
|
||||||
|
{@html iconSrc} <!-- TODO: !! MITM attack very possible here so we'll need to purify this later! -->
|
||||||
|
</div>
|
Loading…
Reference in a new issue