feat(api,web): support CBR — extraction RAR, scan et lecture d'albums
- api: cbr utilitaire (extraction RAR), scanner/métadonnées (+ tests), books, schéma - web: ReaderPage/locators (+ tests), mockData, types partagés - deps: pnpm-lock Refs: #17
This commit is contained in:
@ -1,5 +1,5 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
import { parseCbzPageLocator, parsePdfPageLocator, pdfPagePercent } from "./locators";
|
||||
import { parseCbrPageLocator, parseCbzPageLocator, parsePdfPageLocator, pdfPagePercent } from "./locators";
|
||||
|
||||
describe("reader locators", () => {
|
||||
it("parses valid PDF page locators", () => {
|
||||
@ -16,6 +16,11 @@ describe("reader locators", () => {
|
||||
expect(parseCbzPageLocator("pdf:page:7")).toBeNull();
|
||||
});
|
||||
|
||||
it("parses CBR page locators", () => {
|
||||
expect(parseCbrPageLocator("cbr:page:9")).toBe(9);
|
||||
expect(parseCbrPageLocator("cbz:page:9")).toBeNull();
|
||||
});
|
||||
|
||||
it("bounds PDF page percentages", () => {
|
||||
expect(pdfPagePercent(2, 4)).toBe(50);
|
||||
expect(pdfPagePercent(8, 4)).toBe(100);
|
||||
|
||||
@ -8,6 +8,11 @@ export function parseCbzPageLocator(locator?: string | null): number | null {
|
||||
return parsePageSuffix(locator);
|
||||
}
|
||||
|
||||
export function parseCbrPageLocator(locator?: string | null): number | null {
|
||||
if (!locator?.startsWith("cbr:page:")) return null;
|
||||
return parsePageSuffix(locator);
|
||||
}
|
||||
|
||||
function parsePageSuffix(locator: string): number | null {
|
||||
const value = Number(locator.split(":").at(-1));
|
||||
return Number.isInteger(value) && value > 0 ? value : null;
|
||||
|
||||
Reference in New Issue
Block a user