Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit ba1fb4f

Browse files
committedMar 31, 2021
Use submission list from base ref for duplicate URL check
Previously, the duplicate URL check was configured to use the submission list at the head ref, where two ocurrences of the URL indicated a duplicate. A more secure approach is to use the submission list at the base ref, and this means that a single ocurrence of the URL indicates a duplicate.
1 parent 06b0502 commit ba1fb4f

File tree

1 file changed

+2
-6
lines changed

1 file changed

+2
-6
lines changed
 

‎main.go

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -246,7 +246,6 @@ func populateSubmission(submissionURL string, listPath *paths.Path) (submissionT
246246

247247
// Check if the URL is already in the index.
248248
listLines, err := listPath.ReadFileAsLines()
249-
occurrences := 0
250249
for _, listURL := range listLines {
251250
listURLObject, err := url.Parse(strings.TrimSpace(listURL))
252251
if err != nil {
@@ -255,11 +254,8 @@ func populateSubmission(submissionURL string, listPath *paths.Path) (submissionT
255254

256255
normalizedListURLObject := normalizeURL(listURLObject)
257256
if normalizedListURLObject.String() == normalizedURLObject.String() {
258-
occurrences++
259-
if occurrences > 1 {
260-
submission.Error = "Submission URL is already in the Library Manager index."
261-
return submission, ""
262-
}
257+
submission.Error = "Submission URL is already in the Library Manager index."
258+
return submission, ""
263259
}
264260
}
265261

0 commit comments

Comments
 (0)
Please sign in to comment.