Fix e.File() being picky with relative paths after 4.7.0 introduced echo.Fs support#2123
Merged
aldas merged 4 commits intolabstack:masterfrom Mar 13, 2022
Merged
Conversation
Codecov Report
@@ Coverage Diff @@
## master #2123 +/- ##
==========================================
- Coverage 92.21% 92.10% -0.11%
==========================================
Files 37 37
Lines 3018 3028 +10
==========================================
+ Hits 2783 2789 +6
- Misses 148 150 +2
- Partials 87 89 +2
Continue to review full report at Codecov.
|
ac5f414 to
a304772
Compare
…cho.Fs support (Go1.16+)
a304772 to
cd3e7f2
Compare
Contributor
Author
|
Absolute paths have similar problem with All these cases must work: func main() {
e := echo.New()
e.Use(middleware.Logger())
e.Use(middleware.Recover())
e.Static("/static1", "./") // curl http://localhost:8080/static1/main.go
dir, _ := os.Getwd()
e.Static("/static2", dir+"/") // curl http://localhost:8080/static2/main.go
e.File("/f1", "./main.go") // curl http://localhost:8080/f1
e.File("/f2", dir+"/main.go") // curl http://localhost:8080/f2
e.GET("/a1", func(c echo.Context) error { // curl http://localhost:8080/a1
return c.Attachment("./main.go", "test")
})
e.GET("/a2", func(c echo.Context) error { // curl http://localhost:8080/a2
return c.Attachment(dir+"/main.go", "test")
})
e.Logger.Fatal(e.Start(":8080"))
} |
….7.0 introduced echo.Fs support
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 e.File() being picky with relative paths after 4.7.0 introduced echo.Fs support (Go 1.16+).
See #2117 (comment)
TLDR:
fs.Fsand to be specificos.DirFs.Opendoes not like path to files starting with./,../and/butos.Opendid not care about that and now old code has problems.