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
cc229aef
Commit
cc229aef
authored
Oct 27, 2015
by
Matthew Holt
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
templates: Parse host successfully when port is implicit (fixes #292)
parent
136119f8
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
15 additions
and
1 deletion
+15
-1
middleware/context.go
middleware/context.go
+4
-0
middleware/context_test.go
middleware/context_test.go
+11
-1
No files found.
middleware/context.go
View file @
cc229aef
...
...
@@ -97,6 +97,10 @@ func (c Context) URI() string {
func
(
c
Context
)
Host
()
(
string
,
error
)
{
host
,
_
,
err
:=
net
.
SplitHostPort
(
c
.
Req
.
Host
)
if
err
!=
nil
{
if
!
strings
.
Contains
(
c
.
Req
.
Host
,
":"
)
{
// common with sites served on the default port 80
return
c
.
Req
.
Host
,
nil
}
return
""
,
err
}
return
host
,
nil
...
...
middleware/context_test.go
View file @
cc229aef
...
...
@@ -232,8 +232,13 @@ func TestHost(t *testing.T) {
},
{
input
:
"localhost"
,
expectedHost
:
"localhost"
,
shouldErr
:
false
,
},
{
input
:
"[::]"
,
expectedHost
:
""
,
shouldErr
:
true
,
// missing port in address
shouldErr
:
true
,
},
}
...
...
@@ -258,6 +263,11 @@ func TestPort(t *testing.T) {
expectedPort
:
""
,
shouldErr
:
true
,
// missing port in address
},
{
input
:
":8080"
,
expectedPort
:
"8080"
,
shouldErr
:
false
,
},
}
for
_
,
test
:=
range
tests
{
...
...
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