Skip to content

fix: use path.Clean for URL paths to fix Windows static file serving#124

Merged
fank merged 2 commits intomainfrom
fix/windows-static-file-serving
Feb 4, 2026
Merged

fix: use path.Clean for URL paths to fix Windows static file serving#124
fank merged 2 commits intomainfrom
fix/windows-static-file-serving

Conversation

@fank
Copy link
Member

@fank fank commented Feb 4, 2026

Summary

  • Fix static file serving returning 404 on Windows by using path.Clean instead of filepath.Clean for URL path validation
  • filepath.Clean converts / to \ on Windows, breaking the path validation since URLs always use forward slashes
  • Add index.html fallback for directory requests (e.g., accessing / now serves /index.html)

Test plan

  • Tested on Windows with v2.1.0-rc3 release - confirmed 404 before fix
  • Built fixed binary and verified static files now load correctly on Windows
  • All existing tests pass

fank added 2 commits February 4, 2026 21:51
filepath.Clean converts forward slashes to backslashes on Windows,
which broke the path validation in paramPath since URL paths always
use forward slashes. This caused all static file requests to return
404 on Windows.

Also add index.html fallback for directory requests.
- Test root path serves index.html
- Test nested paths with forward slashes work correctly
- Add paramPath unit tests for path validation
@github-actions
Copy link

github-actions bot commented Feb 4, 2026

Merging this branch will increase overall coverage

Impacted Packages Coverage Δ 🤖
github.com/OCAP2/web/internal/server 44.11% (+0.07%) 👍

Coverage by file

Changed files (no unit tests)

Changed File Coverage Δ Total Covered Missed 🤖
github.com/OCAP2/web/internal/server/handler.go 39.89% (+0.22%) 747 (+6) 298 (+4) 449 (+2) 👍

Please note that the "Total", "Covered", and "Missed" counts above refer to code statements instead of lines of code. The value in brackets refers to the test coverage of that file in the old version of the code.

Changed unit test files

  • github.com/OCAP2/web/internal/server/handler_test.go

@fank fank merged commit a926057 into main Feb 4, 2026
2 checks passed
@fank fank deleted the fix/windows-static-file-serving branch February 4, 2026 20:54
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