mirror of
https://github.com/caddyserver/caddy.git
synced 2025-02-22 19:17:56 +08:00
ext: Only append extension if request is not for directory (fixes #173)
This commit is contained in:
parent
16f18bfeff
commit
4d066b7e30
1
dist/CHANGES.txt
vendored
1
dist/CHANGES.txt
vendored
@ -6,6 +6,7 @@ CHANGES
|
|||||||
- browse: Sort by clicking column heading or using query string
|
- browse: Sort by clicking column heading or using query string
|
||||||
- core: Serving hostname that doesn't resolve issues warning then listens on 0.0.0.0
|
- core: Serving hostname that doesn't resolve issues warning then listens on 0.0.0.0
|
||||||
- errors: Missing error page during parse time is warning, not error
|
- errors: Missing error page during parse time is warning, not error
|
||||||
|
- ext: Extension only appended if request path does not end in /
|
||||||
- fastcgi: Fix for backend responding without status text
|
- fastcgi: Fix for backend responding without status text
|
||||||
- fastcgi: Fix PATH_TRANSLATED when PATH_INFO is empty (RFC 3875)
|
- fastcgi: Fix PATH_TRANSLATED when PATH_INFO is empty (RFC 3875)
|
||||||
- gzip: Enable by file path and/or extension
|
- gzip: Enable by file path and/or extension
|
||||||
|
@ -31,7 +31,7 @@ type Ext struct {
|
|||||||
// ServeHTTP implements the middleware.Handler interface.
|
// ServeHTTP implements the middleware.Handler interface.
|
||||||
func (e Ext) ServeHTTP(w http.ResponseWriter, r *http.Request) (int, error) {
|
func (e Ext) ServeHTTP(w http.ResponseWriter, r *http.Request) (int, error) {
|
||||||
urlpath := strings.TrimSuffix(r.URL.Path, "/")
|
urlpath := strings.TrimSuffix(r.URL.Path, "/")
|
||||||
if path.Ext(urlpath) == "" {
|
if path.Ext(urlpath) == "" && r.URL.Path[len(r.URL.Path)-1] != '/' {
|
||||||
for _, ext := range e.Extensions {
|
for _, ext := range e.Extensions {
|
||||||
if resourceExists(e.Root, urlpath+ext) {
|
if resourceExists(e.Root, urlpath+ext) {
|
||||||
r.URL.Path = urlpath + ext
|
r.URL.Path = urlpath + ext
|
||||||
|
Loading…
x
Reference in New Issue
Block a user