Repository navigation
Normalize E2E base-path handling and harden static file serving in run_e2e.mjs - #6
Merged
Merged
Conversation
Copilot
AI
changed the title
[WIP] Fix code for all comments in review thread
Normalize E2E base-path handling and harden static file serving in Aug 1, 2026
run_e2e.mjs
yf-1229
marked this pull request as ready for review
August 1, 2026 02:45
Contributor
There was a problem hiding this comment.
Pull request overview
This PR updates the web/e2e/run_e2e.mjs E2E runner’s static server to behave consistently when simulating GitHub Pages-style subpaths and to constrain static file resolution to the dist/ output directory.
Changes:
- Normalizes
E2E_BASE_PATHto a consistent''or'/name'form (no trailing slash). - Hardens request URL handling by defaulting missing
req.urlto'/'and normalizing to a leading/. - Switches static serving to
resolve()+DIST_ROOTboundary checks to prevent path traversal outsidedist/.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+49
to
53
| return; | ||
| } | ||
| if (!existsSync(p)) { res.writeHead(404); res.end(); return; } | ||
| const ext = extname(p); | ||
| res.writeHead(200, { 'Content-Type': mime[ext] || 'application/octet-stream' }); |
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.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.
This PR addresses review-thread feedback on
web/e2e/run_e2e.mjs:E2E_BASE_PATHhandling was brittle for slash variants, and request-path handling could throw on missing URLs and allow traversal outsidedist/. It updates path normalization and request resolution so subpath E2E runs are robust and constrained to the build output root.Base-path normalization
E2E_BASE_PATHso inputs like/coBroc,coBroc/, and/coBroc/resolve consistently to/coBroc.Request URL safety
req.urlwith a stable default ('/').Traversal protection for static serving
DIST_ROOT.dist/with403.