Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
caddy
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
caddy
Commits
13d9bcc0
Commit
13d9bcc0
authored
Mar 24, 2015
by
Matthew Holt
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Clean URL middleware handles URLs ending with /
parent
ba0d63d7
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
5 additions
and
3 deletions
+5
-3
middleware/extensionless/extensionless.go
middleware/extensionless/extensionless.go
+5
-3
No files found.
middleware/extensionless/extensionless.go
View file @
13d9bcc0
...
@@ -8,6 +8,7 @@ import (
...
@@ -8,6 +8,7 @@ import (
"net/http"
"net/http"
"os"
"os"
"path"
"path"
"strings"
"github.com/mholt/caddy/middleware"
"github.com/mholt/caddy/middleware"
)
)
...
@@ -41,10 +42,11 @@ func New(c middleware.Controller) (middleware.Middleware, error) {
...
@@ -41,10 +42,11 @@ func New(c middleware.Controller) (middleware.Middleware, error) {
// ServeHTTP implements the http.Handler interface.
// ServeHTTP implements the http.Handler interface.
func
(
e
Extensionless
)
ServeHTTP
(
w
http
.
ResponseWriter
,
r
*
http
.
Request
)
{
func
(
e
Extensionless
)
ServeHTTP
(
w
http
.
ResponseWriter
,
r
*
http
.
Request
)
{
if
path
.
Ext
(
r
.
URL
.
Path
)
==
""
{
urlpath
:=
strings
.
TrimSuffix
(
r
.
URL
.
Path
,
"/"
)
if
path
.
Ext
(
urlpath
)
==
""
{
for
_
,
ext
:=
range
e
.
Extensions
{
for
_
,
ext
:=
range
e
.
Extensions
{
if
resourceExists
(
e
.
Root
,
r
.
URL
.
P
ath
+
ext
)
{
if
resourceExists
(
e
.
Root
,
urlp
ath
+
ext
)
{
r
.
URL
.
Path
=
r
.
URL
.
P
ath
+
ext
r
.
URL
.
Path
=
urlp
ath
+
ext
break
break
}
}
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment