Skip to content

Commit 757c8e2

Browse files
authored
Merge pull request #185 from per1234/fix-url-check
Use most appropriate function for checking URL
2 parents 539e940 + 3adc412 commit 757c8e2

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

internal/rule/rulefunction/library.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -1011,7 +1011,7 @@ func LibraryPropertiesUrlFieldDeadLink() (result ruleresult.Type, output string)
10111011
}
10121012

10131013
logrus.Tracef("Checking URL: %s", url)
1014-
httpResponse, err := http.Get(url)
1014+
httpResponse, err := http.Head(url)
10151015
if err != nil {
10161016
return ruleresult.Fail, err.Error()
10171017
}

internal/rule/rulefunction/library_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -751,7 +751,7 @@ func TestLibraryPropertiesUrlFieldDeadLink(t *testing.T) {
751751
testTables := []libraryRuleFunctionTestTable{
752752
{"Unable to load", "InvalidLibraryProperties", ruleresult.NotRun, ""},
753753
{"Not defined", "MissingFields", ruleresult.NotRun, ""},
754-
{"Bad URL", "BadURL", ruleresult.Fail, "^Get \"http://invalid/\": dial tcp: lookup invalid:"},
754+
{"Bad URL", "BadURL", ruleresult.Fail, "^Head \"http://invalid/\": dial tcp: lookup invalid:"},
755755
{"HTTP error 404", "URL404", ruleresult.Fail, "^404 Not Found$"},
756756
{"Good URL", "Recursive", ruleresult.Pass, ""},
757757
}

0 commit comments

Comments
 (0)