pdf-free.openapps.xyz

Source

This app’s code and revision history are public. Download a copy or explore the files below.

Public
The app’s code and revision history are public.
Owned app · rev 0341fee61377
Run it yourself
Take the whole tree and run it on your own machine. The download needs no account. Cloning needs a sign-in.
Download .zip
bounded clone 7716a56ff3432bc0c1e4837c
A copy you download is not bounded. The guarantees this app runs under - declared egress, proven invariants, writes that fail closed - live in the runtime serving this page, not in the files. What you get is auditable source you can read and run, with no runtime guarantees attached.
← All files
src/lib/ranges.ts
// Page ranges people type for splitting, like "1-3, 5, 8-".

/**
 * Reads ranges against `total` pages. Returns 1-based inclusive pairs,
 * or a sentence saying what is wrong.
 */
export function parseRanges(text: string, total: number): [number, number][] | string {
  const parts = text.split(/[,;]+/).map((s) => s.trim()).filter(Boolean);
  if (!parts.length) return "Type the pages for each new PDF, like 1-3, 4-6.";
  const out: [number, number][] = [];
  for (const part of parts) {
    const m = part.match(/^(\d*)\s*[-–]\s*(\d*)$|^(\d+)$/);
    if (!m) return `"${part}" is not a page or a range. Use numbers like 2 or 4-7.`;
    const a = Number(m[3] ?? (m[1] || 1));
    const b = Number(m[3] ?? (m[2] || total));
    if (a < 1 || b < 1 || a > total || b > total) return `There ${total === 1 ? "is 1 page" : `are ${total} pages`}, so ${part} is out of range.`;
    if (a > b) return `${part} goes backwards. Write it as ${b}-${a}.`;
    out.push([a, b]);
  }
  return out;
}

Change history

Quality pass: compress, PDF to JPG, phone layout, job links, llms.txt and index.md
0341fee613 · 5 hours ago
Bounded source sync
f00de5deb0 · 1 day ago
Bounded source sync
3c8124e576 · 1 day ago
Bounded source sync
5c14663e0f · 1 day ago
Bounded source sync
ee5c852f40 · 1 day ago