fix: properly serve .plain.html requests for documents in local content directory#2733
Open
shsteimer wants to merge 6 commits into
Open
fix: properly serve .plain.html requests for documents in local content directory#2733shsteimer wants to merge 6 commits into
shsteimer wants to merge 6 commits into
Conversation
… fixture Parse the full HTML document and return only the innerHTML of <main> rather than sending the raw file content. Uses existing hast-util-select and hast-util-to-html deps. Test fixture updated to use a realistic full document and a multiline fragment string for readability. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
|
This PR will trigger a patch release when merged. |
…hast Remove inner try/catch in favor of upfront path rewriting — .plain.html is a virtual URL convention and AEM never stores such files in content/. Extract <main> innerHTML using hast-util-select/to-html (already transitive deps) rather than sending the raw file. Update test fixture to use a realistic full HTML document and tighten assertion to strictEqual. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
shsteimer
commented
May 27, 2026
| let htmlContent = await readFile(contentFilePath, 'utf-8'); | ||
| // .plain.html is a virtual URL convention — AEM never stores .plain.html files, | ||
| // so always read the corresponding .html file and serve the <main> fragment. | ||
| const isPlainFallback = contentFilePath.endsWith('.plain.html'); |
Author
There was a problem hiding this comment.
worth noting that this assumes there will never be a .plain.html file in the content checkout directory. If that assumption doesn't hold, then this will need to be adapted to handle that case.
Run npm install to restore @adobe/helix-shared-process-queue and xdg-basedir that were in package.json but absent from node_modules. Expand single-line if in extractMainContent to satisfy the curly and max-statements-per-line ESLint rules. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
kptdobe
requested changes
May 28, 2026
| * @param {string} html full HTML document | ||
| * @returns {string} innerHTML of <main>, or original html if no <main> present | ||
| */ | ||
| extractMainContent(html) { |
Comment on lines
+475
to
+478
| res.set({ | ||
| 'content-type': 'text/html; charset=utf-8', | ||
| 'access-control-allow-origin': '*', | ||
| }); |
Contributor
There was a problem hiding this comment.
why is access-control-allow-origin needed ? this is not happening in prod...
Author
There was a problem hiding this comment.
It looks to me like we are setting access-control-allow-origin: * on all responses from the local dev server, originally added in #1900. so this just follows that same pattern as all other locally-served responses in this handler (lines 512, 521, 541, 551).
Adds tests for the normal case, empty <main>, no <main> fallback, nested markup, and whitespace-only content. Also removes a redundant inline comment made obvious by the function name. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
fix: #2732
Please ensure your pull request adheres to the following guidelines:
Related Issues
Thanks for contributing!