From 4d066b7e30754a02dc6a88e77abd093b91cced62 Mon Sep 17 00:00:00 2001 From: Matthew Holt Date: Wed, 1 Jul 2015 11:35:52 -0600 Subject: [PATCH] ext: Only append extension if request is not for directory (fixes #173) --- dist/CHANGES.txt | 1 + middleware/extensions/ext.go | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/dist/CHANGES.txt b/dist/CHANGES.txt index b76e2ee3..08211dcb 100644 --- a/dist/CHANGES.txt +++ b/dist/CHANGES.txt @@ -6,6 +6,7 @@ CHANGES - 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 - 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 PATH_TRANSLATED when PATH_INFO is empty (RFC 3875) - gzip: Enable by file path and/or extension diff --git a/middleware/extensions/ext.go b/middleware/extensions/ext.go index c2852cbb..2444319f 100644 --- a/middleware/extensions/ext.go +++ b/middleware/extensions/ext.go @@ -31,7 +31,7 @@ type Ext struct { // ServeHTTP implements the middleware.Handler interface. func (e Ext) ServeHTTP(w http.ResponseWriter, r *http.Request) (int, error) { 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 { if resourceExists(e.Root, urlpath+ext) { r.URL.Path = urlpath + ext