mirror of
https://github.com/misode/misode.github.io.git
synced 2026-04-23 23:27:09 +00:00
Remove unnecessary json parsing for presets and snippets
This commit is contained in:
@@ -139,7 +139,7 @@ export async function fetchPreset(versionId: VersionId, registry: string, id: st
|
||||
url = `${mcmeta(version, type)}/${type}/minecraft/${registry}/${id}.json`
|
||||
}
|
||||
const res = await fetch(url)
|
||||
return await res.json()
|
||||
return await res.text()
|
||||
} catch (e) {
|
||||
throw new Error(`Error occurred while fetching ${registry} preset ${id}: ${message(e)}`)
|
||||
}
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
import lz from 'lz-string'
|
||||
import { safeJsonParse } from '../Utils.js'
|
||||
import type { VersionId } from './Versions.js'
|
||||
|
||||
const API_PREFIX = 'https://snippets.misode.workers.dev'
|
||||
@@ -30,7 +29,7 @@ export async function getSnippet(id: string) {
|
||||
const snippet = await fetchApi(`/${id}`)
|
||||
return {
|
||||
...snippet,
|
||||
data: safeJsonParse(lz.decompressFromBase64(snippet.data) ?? '{}') ?? {},
|
||||
text: lz.decompressFromBase64(snippet.data) ?? '{}',
|
||||
}
|
||||
} catch (e) {
|
||||
if (e instanceof Error) {
|
||||
|
||||
Reference in New Issue
Block a user