Skip to content

fix(annotate): resolve shared HTML assets within selected folders - #1568

Open
leoreisdias wants to merge 1 commit into
backnotprop:mainfrom
leoreisdias:feat/folder-html-assets
Open

leoreisdias wants to merge 1 commit into
backnotprop:mainfrom
leoreisdias:feat/folder-html-assets

Conversation

@leoreisdias

Copy link
Copy Markdown
Contributor

Problem

Folder annotation loses shared styles and scripts when an HTML page references assets outside its own directory, even when those assets are inside the selected folder. For example, annotating course/ leaves lessons/lesson.html unstyled when it links to ../assets/lesson.css.

Fix

Use the selected folder as the permitted asset root, while resolving relative references from each HTML document's directory. The same folder context is used by the Bun and Pi servers and by portable HTML sharing. This lets nested pages reuse a common assets/ directory without moving files or inlining their CSS and JavaScript.

Single-file annotation retains its existing directory scope. Asset reads still enforce realpath containment, including rejection of symlinks pointing outside the permitted root.

Review focus

The main boundary is htmlAssetContext: root and document paths are canonicalized together so selecting a folder through a symlink works. URL decoding applies only to authored references, preserving literal % characters in filesystem directory names. The shared rewriter carries the document-relative base through HTML attributes, inline CSS, and srcset.

Verification

  • 48 focused tests passed across the Bun asset suite, shared resolver suite, and Pi HTML freshness suite.
  • Regression coverage exercises folder API CSS/JS responses in both runtimes, portable sharing, symlink containment, and live/shared assets under percent-containing directories.
  • Full repository typecheck passed using the workspace-installed TypeScript compiler on PATH.
  • Manually opened a real lesson folder with the local source CLI; the reporter confirmed the result looked good.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant