mirror of
https://github.com/zadam/trilium.git
synced 2025-12-29 02:34:25 +01:00
feat(icon_pack): check if JSON is parsable
This commit is contained in:
parent
af4fc11a4e
commit
a56a5fe1f5
12
apps/server/src/services/icon_packs.spec.ts
Normal file
12
apps/server/src/services/icon_packs.spec.ts
Normal file
@ -0,0 +1,12 @@
|
||||
import { buildNote } from "../test/becca_easy_mocking";
|
||||
import { processIconPack } from "./icon_packs";
|
||||
|
||||
describe("Processing icon packs", () => {
|
||||
it("doesn't crash if icon pack is incorrect type", () => {
|
||||
const iconPack = processIconPack(buildNote({
|
||||
type: "text",
|
||||
content: "Foo"
|
||||
}));
|
||||
expect(iconPack).toBeFalsy();
|
||||
});
|
||||
});
|
||||
18
apps/server/src/services/icon_packs.ts
Normal file
18
apps/server/src/services/icon_packs.ts
Normal file
@ -0,0 +1,18 @@
|
||||
import type BNote from "../becca/entities/bnote";
|
||||
import log from "./log";
|
||||
|
||||
interface Manifest {
|
||||
name: string;
|
||||
prefix: string;
|
||||
icons: Record<string, string>;
|
||||
}
|
||||
|
||||
export function processIconPack(iconPackNote: BNote) {
|
||||
const manifest = iconPackNote.getJsonContentSafely();
|
||||
if (!manifest) {
|
||||
log.error(`Icon pack is missing JSON manifest (or has syntax errors): ${iconPackNote.title} (${iconPackNote.noteId})`);
|
||||
return;
|
||||
}
|
||||
|
||||
console.log("Got manifest", manifest);
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user