remove error from return of parseLinks as it's not needed

This commit is contained in:
swaits committed 2015-02-16 23:08:33 -08:00
1 parent f16be33dbd
commit 6edd18e361
3 files changed
+4 -7

No files matched your search

+1 -1
View File
@@ -102,7 +102,7 @@ func crawlItem(item *httpItem, rchan chan<- *httpItem) {
} }
// parse links // parse links
title, links, _ := parseLinks(text) // TODO remove error from parseLinks, not needed title, links := parseLinks(text) // TODO remove error from parseLinks, not needed
if err != nil { if err != nil {
item.linkType = tBroken item.linkType = tBroken
rchan <- item rchan <- item
+2 -2
View File
@@ -11,7 +11,7 @@ var reTitle = regexp.MustCompile(`(?i)<\s*title\s*>([^<]*)<\s*\/\s*title`)
// parseLinks takes a string and attempts to parse any html title and all links out of it, // parseLinks takes a string and attempts to parse any html title and all links out of it,
// and returns a slice of the captures found // and returns a slice of the captures found
func parseLinks(s string) (string, []string, error) { func parseLinks(s string) (string, []string) {
// find the title, or default to empty // find the title, or default to empty
title := "" title := ""
titleMatches := reTitle.FindStringSubmatch(s) titleMatches := reTitle.FindStringSubmatch(s)
@@ -25,5 +25,5 @@ func parseLinks(s string) (string, []string, error) {
for _, match := range reURL.FindAllStringSubmatch(s, -1) { for _, match := range reURL.FindAllStringSubmatch(s, -1) {
results = append(results, match[2]) results = append(results, match[2])
} }
return title, results, nil return title, results
} }
+1 -4
View File
@@ -16,10 +16,7 @@ func TestSimpleParse(t *testing.T) {
<script href="scripts/blah.js"/> <script href="scripts/blah.js"/>
</body> </body>
</html>` </html>`
title, matches, err := parseLinks(doc) title, matches := parseLinks(doc)
if err != nil {
t.Error(err)
}
if title != "Test Page" { if title != "Test Page" {
t.Error("got wrong title") t.Error("got wrong title")
} }