Files
bookmarkmagic/tests/fixtures/csv-comma.csv
poli0981andClaude Opus 5 6879558a97 feat(core): implement the pure core library with fixtures and tests (Phase 1)
Implements src/lib/core/ per docs/04 and docs/05: model, timestamps,
normalize-url, csv-path, detect-format, three parsers, four serializers,
dedupe and diff. 175 tests, 97% statements / 91% branches on core, well over
the 90/90/85 gate. `npm run verify` green.

The flagship round-trip suite asserts
`parse(serialize(t)).roots deepEquals project(t, format)` with zero warnings,
across sample trees, every browser fixture and 200 seeded random trees per
format — 600 round-trips, with a nasty-title pool covering quotes, commas,
CR/LF, emoji, RTL, `</a>` and path slashes.

Seven defects found by an adversarial review pass and fixed here, each with a
regression test:

- normalize-url rebuilt a bare-origin key from protocol+host, discarding
  userinfo — https://alice@host/ and https://bob@host/ collapsed to one key,
  so one of them would be silently dropped on import.
- The Netscape walk picked a single root <DL>. Against the real Safari shape
  (top-level <DT><H3> with no wrapper, Mozilla bug 801450) that returns the
  first folder's INNER list and reports a clean parse having dropped every
  other top-level folder. Replaced with a document-order pass over <body> that
  accepts both entry-point kinds, skipping child lists already consumed via an
  explicit </DT> so subtrees are not emitted twice. The old test named this
  case but its fixture had a wrapper, so the branch was never exercised.
- escapeHtml emitted CR verbatim; the HTML tokenizer normalizes CR/CRLF to LF
  before character references are decoded, so any title carrying \r from BM
  JSON or a quoted CSV field was mutated by an HTML round trip.
- joinPath(['']) collapsed to '', indistinguishable from "no path", so a
  folder with an empty title dissolved on CSV re-import.
- parseCsv counted only bookmark rows against MAX_NODES, so folders
  synthesized from deep paths bypassed the cap entirely.
- detect-format required a literal unquoted `folder_path` prefix and so
  rejected fully quoted headers that parseCsv itself accepts; both now share
  one matcher.
- Markdown formatUrl encoded `>` but not `<` or line endings, producing an
  angle-bracket destination CommonMark rejects.

docs/04 §1.2 is corrected too: its stated fallback ("walk the top-level <DT>
children of body") is itself lossy on files that mix a wrapper with loose
<DT>s. Also adds .gitattributes so fixture CRLF survives a clone — EOL
normalization would otherwise make a fresh checkout test different bytes.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-07-26 06:13:53 +07:00

210 B

1folder_pathtitleurladd_date
2Bookmarks bar/Dev toolsGitHubhttps://github.com/1751500000
3Examplehttps://example.com/1751500001
4Escaped\/slashOdd folderhttps://odd.example/