Skip to content

Commit 4da47c9

Browse files
committed
Fix URL normalization
1 parent 4379986 commit 4da47c9

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

opam/opam_file.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ type PinDepend struct {
3939
// Returns dep.
4040
func (dep *PinDepend) Normalize() *PinDepend {
4141
dep.Package = strings.TrimSuffix(dep.Package, ".dev")
42-
if strings.HasPrefix("https://", dep.URL) {
42+
if strings.HasPrefix(dep.URL, "https://") {
4343
dep.URL = "git+" + dep.URL
4444
}
4545
return dep

opam/opam_file_test.go

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -177,13 +177,23 @@ func TestAddPinDepend_Update(t *testing.T) {
177177
assert.True(t, found, "perennial not found after update")
178178
}
179179

180+
func TestNormalize(t *testing.T) {
181+
dep := PinDepend{
182+
Package: "new-package",
183+
URL: "https://example.com/package",
184+
Commit: "abc123",
185+
}
186+
dep.Normalize()
187+
assert.Equal(t, "git+https://example.com/package", dep.URL)
188+
}
189+
180190
func TestAddPinDepend_Add(t *testing.T) {
181191
f := parseString(t, exampleOpam)
182192

183193
// Add new dependency
184194
f.AddPinDepend(PinDepend{
185195
Package: "new-package",
186-
URL: "git+https://example.com/package",
196+
URL: "https://example.com/package",
187197
Commit: "abc123",
188198
})
189199

0 commit comments

Comments
 (0)