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
fd8fe24b
Commit
fd8fe24b
authored
Jun 22, 2016
by
Abiola Ibrahim
Committed by
GitHub
Jun 22, 2016
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #899 from abiosoft/master
Minor refactor for rewrite.
parents
fbad4e15
28160389
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
4 additions
and
8 deletions
+4
-8
caddyhttp/rewrite/to.go
caddyhttp/rewrite/to.go
+4
-8
No files found.
caddyhttp/rewrite/to.go
View file @
fd8fe24b
...
...
@@ -28,17 +28,13 @@ func To(fs http.FileSystem, r *http.Request, to string, replacer httpserver.Repl
query
=
tparts
[
1
]
}
if
strings
.
HasSuffix
(
tparts
[
0
],
"/"
)
&&
!
strings
.
HasSuffix
(
t
,
"/"
)
{
t
+=
"/"
}
// add trailing slash for directories, if present
if
strings
.
HasSuffix
(
v
,
"/"
)
&&
!
strings
.
HasSuffix
(
t
,
"/"
)
{
if
strings
.
HasSuffix
(
tparts
[
0
]
,
"/"
)
&&
!
strings
.
HasSuffix
(
t
,
"/"
)
{
t
+=
"/"
}
// validate file
if
isV
alidFile
(
fs
,
t
)
{
if
v
alidFile
(
fs
,
t
)
{
break
}
}
...
...
@@ -70,9 +66,9 @@ func To(fs http.FileSystem, r *http.Request, to string, replacer httpserver.Repl
return
RewriteDone
}
//
isV
alidFile checks if file exists on the filesystem.
//
v
alidFile checks if file exists on the filesystem.
// if file ends with `/`, it is validated as a directory.
func
isV
alidFile
(
fs
http
.
FileSystem
,
file
string
)
bool
{
func
v
alidFile
(
fs
http
.
FileSystem
,
file
string
)
bool
{
if
fs
==
nil
{
return
false
}
...
...
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