Skip to content

fix(static): use path separator instead of hardcoded slash#190

Merged
pi0 merged 1 commit intoh3js:mainfrom
magne4000:main
Mar 3, 2026
Merged

fix(static): use path separator instead of hardcoded slash#190
pi0 merged 1 commit intoh3js:mainfrom
magne4000:main

Conversation

@magne4000
Copy link
Contributor

@magne4000 magne4000 commented Mar 3, 2026

Fixes #189

Root cause

Prior to a317982, dir was built with a hardcoded "/" suffix:

  const dir = resolve(options.dir) + "/";

On Windows, resolve() and join() both produce backslash paths, but dir ended with a forward slash, so startsWith always returned false, causing every file request to be skipped.

Summary by CodeRabbit

  • Bug Fixes
    • Improved static file serving to use platform-specific path handling, ensuring proper file access across Windows, macOS, and Linux environments.

@magne4000 magne4000 requested a review from pi0 as a code owner March 3, 2026 13:22
@coderabbitai
Copy link

coderabbitai bot commented Mar 3, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between f2aa00b and a317982.

📒 Files selected for processing (1)
  • src/static.ts

📝 Walkthrough

Walkthrough

Modifies src/static.ts to replace hard-coded forward slash path separator with platform-specific separator from node:path module when constructing the static directory path, enabling proper path resolution on non-Unix operating systems.

Changes

Cohort / File(s) Summary
Path Separator Normalization
src/static.ts
Replaced Unix-style forward slash "/" with OS-appropriate path separator from node:path in static directory path construction to support Windows and other non-Unix platforms.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~3 minutes

Poem

🐰 A slash through the code, now platform-aware,
Windows and Unix, treated with care,
Static files served on every OS ground,
Two tiny lines fixed, and bugs are unwound! 🎉

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and specifically describes the main change: replacing a hardcoded slash with a platform-specific path separator in the static module.
Linked Issues check ✅ Passed The changes directly address the Windows path-separator incompatibility issue #189 by replacing hardcoded forward slashes with platform-appropriate separators, enabling correct static file serving on Windows.
Out of Scope Changes check ✅ Passed All changes are scoped to fixing the path-separator issue in src/static.ts, with no extraneous modifications or unrelated code alterations present.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Tip

Try Coding Plans. Let us write the prompt for your AI agent so you can ship faster (with fewer bugs).
Share your feedback on Discord.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@pi0 pi0 merged commit a8a0225 into h3js:main Mar 3, 2026
8 checks passed
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.

serveStatic fails on Windows

2 participants