Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
N
nexpie-grafana-theme
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Registry
Registry
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Kornkitt Poolsup
nexpie-grafana-theme
Commits
0495499b
Unverified
Commit
0495499b
authored
Jan 21, 2019
by
Marcus Efraimsson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix ip address parsing of loopback address
parent
2e97d39a
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
6 additions
and
2 deletions
+6
-2
pkg/util/ip_address.go
+4
-2
pkg/util/ip_address_test.go
+2
-0
No files found.
pkg/util/ip_address.go
View file @
0495499b
...
...
@@ -7,11 +7,13 @@ import (
// ParseIPAddress parses an IP address and removes port and/or IPV6 format
func
ParseIPAddress
(
input
string
)
string
{
var
s
string
s
:=
input
lastIndex
:=
strings
.
LastIndex
(
input
,
":"
)
if
lastIndex
!=
-
1
{
s
=
input
[
:
lastIndex
]
if
lastIndex
>
0
&&
input
[
lastIndex
-
1
:
lastIndex
]
!=
":"
{
s
=
input
[
:
lastIndex
]
}
}
s
=
strings
.
Replace
(
s
,
"["
,
""
,
-
1
)
...
...
pkg/util/ip_address_test.go
View file @
0495499b
...
...
@@ -10,5 +10,7 @@ func TestParseIPAddress(t *testing.T) {
Convey
(
"Test parse ip address"
,
t
,
func
()
{
So
(
ParseIPAddress
(
"192.168.0.140:456"
),
ShouldEqual
,
"192.168.0.140"
)
So
(
ParseIPAddress
(
"[::1:456]"
),
ShouldEqual
,
"127.0.0.1"
)
So
(
ParseIPAddress
(
"[::1]"
),
ShouldEqual
,
"127.0.0.1"
)
So
(
ParseIPAddress
(
"192.168.0.140"
),
ShouldEqual
,
"192.168.0.140"
)
})
}
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