Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
H
helm3
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
go
helm3
Commits
3b4d7164
Commit
3b4d7164
authored
Nov 30, 2016
by
Matt Butcher
Committed by
GitHub
Nov 30, 2016
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #1603 from technosophos/fix/1588-url-mismatch
fix(helm): improve URL comparison logic
parents
29e3fa9c
a59604f4
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
33 additions
and
0 deletions
+33
-0
manager.go
cmd/helm/downloader/manager.go
+9
-0
manager_test.go
cmd/helm/downloader/manager_test.go
+24
-0
No files found.
cmd/helm/downloader/manager.go
View file @
3b4d7164
...
@@ -313,6 +313,8 @@ func (m *Manager) parallelRepoUpdate(repos []*repo.Entry) {
...
@@ -313,6 +313,8 @@ func (m *Manager) parallelRepoUpdate(repos []*repo.Entry) {
func
urlsAreEqual
(
a
,
b
string
)
bool
{
func
urlsAreEqual
(
a
,
b
string
)
bool
{
au
,
err
:=
url
.
Parse
(
a
)
au
,
err
:=
url
.
Parse
(
a
)
if
err
!=
nil
{
if
err
!=
nil
{
a
=
filepath
.
Clean
(
a
)
b
=
filepath
.
Clean
(
b
)
// If urls are paths, return true only if they are an exact match
// If urls are paths, return true only if they are an exact match
return
a
==
b
return
a
==
b
}
}
...
@@ -320,6 +322,13 @@ func urlsAreEqual(a, b string) bool {
...
@@ -320,6 +322,13 @@ func urlsAreEqual(a, b string) bool {
if
err
!=
nil
{
if
err
!=
nil
{
return
false
return
false
}
}
for
_
,
u
:=
range
[]
*
url
.
URL
{
au
,
bu
}
{
if
u
.
Path
==
""
{
u
.
Path
=
"/"
}
u
.
Path
=
filepath
.
Clean
(
u
.
Path
)
}
return
au
.
String
()
==
bu
.
String
()
return
au
.
String
()
==
bu
.
String
()
}
}
...
...
cmd/helm/downloader/manager_test.go
View file @
3b4d7164
...
@@ -135,3 +135,27 @@ func TestGetRepoNames(t *testing.T) {
...
@@ -135,3 +135,27 @@ func TestGetRepoNames(t *testing.T) {
}
}
}
}
}
}
func
TestUrlsAreEqual
(
t
*
testing
.
T
)
{
for
_
,
tt
:=
range
[]
struct
{
a
,
b
string
match
bool
}{
{
"http://example.com"
,
"http://example.com"
,
true
},
{
"http://example.com"
,
"http://another.example.com"
,
false
},
{
"https://example.com"
,
"https://example.com"
,
true
},
{
"http://example.com/"
,
"http://example.com"
,
true
},
{
"https://example.com"
,
"http://example.com"
,
false
},
{
"http://example.com/foo"
,
"http://example.com/foo/"
,
true
},
{
"http://example.com/foo//"
,
"http://example.com/foo/"
,
true
},
{
"http://example.com/./foo/"
,
"http://example.com/foo/"
,
true
},
{
"http://example.com/bar/../foo/"
,
"http://example.com/foo/"
,
true
},
{
"/foo"
,
"/foo"
,
true
},
{
"/foo"
,
"/foo/"
,
true
},
{
"/foo/."
,
"/foo/"
,
true
},
}
{
if
tt
.
match
!=
urlsAreEqual
(
tt
.
a
,
tt
.
b
)
{
t
.
Errorf
(
"Expected %q==%q to be %t"
,
tt
.
a
,
tt
.
b
,
tt
.
match
)
}
}
}
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