Skip to content

Commit 630c1e2

Browse files
Merge pull request #2257 from Devils-Knight/fix2
[FIX] Compare extra slash in directory path before adding ecosystem for it
2 parents f1c6979 + cb9e08f commit 630c1e2

File tree

4 files changed

+20
-1
lines changed

4 files changed

+20
-1
lines changed

remediation/dependabot/dependabotconfig.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ func UpdateDependabotConfig(dependabotConfig string) (*UpdateDependabotConfigRes
105105
for _, Update := range updateDependabotConfigRequest.Ecosystems {
106106
updateAlreadyExist := false
107107
for _, update := range configMetadata.Updates {
108-
if update.PackageEcosystem == Update.PackageEcosystem && update.Directory == Update.Directory {
108+
if update.PackageEcosystem == Update.PackageEcosystem && (update.Directory == Update.Directory || update.Directory == Update.Directory+"/") {
109109
updateAlreadyExist = true
110110
break
111111
}

remediation/dependabot/dependabotconfig_test.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,11 @@ func TestConfigDependabotFile(t *testing.T) {
4848
Ecosystems: []Ecosystem{{"npm", "/sample", "daily"}},
4949
isChanged: true,
5050
},
51+
{
52+
fileName: "extra-slash.yml",
53+
Ecosystems: []Ecosystem{{"npm", "/sample", "daily"}},
54+
isChanged: false,
55+
},
5156
}
5257

5358
for _, test := range tests {
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
version: 2
2+
updates:
3+
- package-ecosystem: "npm"
4+
# Files stored in `app` directory
5+
directory: "/sample/"
6+
schedule:
7+
interval: "daily"
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
version: 2
2+
updates:
3+
- package-ecosystem: "npm"
4+
# Files stored in `app` directory
5+
directory: "/sample/"
6+
schedule:
7+
interval: "daily"

0 commit comments

Comments
 (0)