Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add support for Windows filepath in fs handlers #1108

Closed
wants to merge 2 commits into from

Conversation

Landryna
Copy link

Not quite sure about any other way around it. Open to discuss
Fixes #1101

Copy link
Collaborator

@erikdubbelboer erikdubbelboer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think this is all that needs to be fixed. I also see places like

fasthttp/fs.go

Line 983 in 4b3460a

indexFilePath := dirPath + "/" + indexName

And I see / being checked in a lot of places.

You also don't need the runtime.GOOS check, filepath.FromSlash takes care of that.

Copy link
Collaborator

@erikdubbelboer erikdubbelboer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Like I said before, there are many other places where / is being used or checked as well. These will all need to be changed for this to work.

I think we also need some tests to check if everything works on Windows. At the moment all FS tests are disabled on windows.

@@ -794,6 +795,10 @@ func (h *fsHandler) handleRequest(ctx *RequestCtx) {
if !ok {
pathStr := string(path)
filePath := h.root + pathStr
switch runtime.GOOS {
case "windows":
filePath = filepath.FromSlash(filePath)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You don't need to check runtime.GOOS if you use filepath.FromSlash. It will take care of that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

FS handlers don't cooperate well with handleRequest on Windows
2 participants