diff options
| -rw-r--r-- | brokenlinks.go | 8 | ||||
| -rw-r--r-- | brokenlinks_test.go | 8 | ||||
| -rw-r--r-- | brokenlinks_worker.go | 8 | ||||
| -rw-r--r-- | testdata/past_result.json | 2 |
4 files changed, 13 insertions, 13 deletions
diff --git a/brokenlinks.go b/brokenlinks.go index 4be4fe8..96580e5 100644 --- a/brokenlinks.go +++ b/brokenlinks.go @@ -32,18 +32,18 @@ type BrokenlinksOptions struct { // BrokenlinksResult store the result of scanning for broken links. type BrokenlinksResult struct { - // PageLinks store the page and its broken links. - PageLinks map[string][]Broken `json:"page_links"` + // BrokenLinks store the page and its broken links. + BrokenLinks map[string][]Broken `json:"broken_links"` } func newBrokenlinksResult() *BrokenlinksResult { return &BrokenlinksResult{ - PageLinks: map[string][]Broken{}, + BrokenLinks: map[string][]Broken{}, } } func (result *BrokenlinksResult) sort() { - for _, listBroken := range result.PageLinks { + for _, listBroken := range result.BrokenLinks { slices.SortFunc(listBroken, func(a, b Broken) int { return strings.Compare(a.Link, b.Link) }) diff --git a/brokenlinks_test.go b/brokenlinks_test.go index 0624e73..3818fbc 100644 --- a/brokenlinks_test.go +++ b/brokenlinks_test.go @@ -101,9 +101,9 @@ func TestBrokenlinks(t *testing.T) { tcase.expError, err.Error()) continue } - //got, _ := json.MarshalIndent(result.PageLinks, ``, ` `) + //got, _ := json.MarshalIndent(result.BrokenLinks, ``, ` `) //t.Logf(`got=%s`, got) - test.Assert(t, tcase.scanUrl, tcase.exp, result.PageLinks) + test.Assert(t, tcase.scanUrl, tcase.exp, result.BrokenLinks) } } @@ -159,8 +159,8 @@ func TestBrokenlinks_pastResult(t *testing.T) { tcase.expError, err.Error()) continue } - got, _ := json.MarshalIndent(result.PageLinks, ``, ` `) + got, _ := json.MarshalIndent(result.BrokenLinks, ``, ` `) t.Logf(`got=%s`, got) - test.Assert(t, tcase.opts.Url, tcase.exp, result.PageLinks) + test.Assert(t, tcase.opts.Url, tcase.exp, result.BrokenLinks) } } diff --git a/brokenlinks_worker.go b/brokenlinks_worker.go index 81283a0..a4e854d 100644 --- a/brokenlinks_worker.go +++ b/brokenlinks_worker.go @@ -160,12 +160,12 @@ func (wrk *brokenlinksWorker) scanAll() (result *BrokenlinksResult, err error) { } // scanPastResult scan only pages reported inside -// [BrokenlinksResult.PageLinks]. +// [BrokenlinksResult.BrokenLinks]. func (wrk *brokenlinksWorker) scanPastResult() ( result *BrokenlinksResult, err error, ) { go func() { - for page := range wrk.pastResult.PageLinks { + for page := range wrk.pastResult.BrokenLinks { var linkq = linkQueue{ parentUrl: nil, url: page, @@ -269,7 +269,7 @@ func (wrk *brokenlinksWorker) processResult( func (wrk *brokenlinksWorker) markBroken(linkq linkQueue) { var parentUrl = linkq.parentUrl.String() - var listBroken = wrk.result.PageLinks[parentUrl] + var listBroken = wrk.result.BrokenLinks[parentUrl] var brokenLink = Broken{ Link: linkq.url, Code: linkq.status, @@ -278,7 +278,7 @@ func (wrk *brokenlinksWorker) markBroken(linkq linkQueue) { brokenLink.Error = linkq.errScan.Error() } listBroken = append(listBroken, brokenLink) - wrk.result.PageLinks[parentUrl] = listBroken + wrk.result.BrokenLinks[parentUrl] = listBroken wrk.seenLink[linkq.url] = linkq.status } diff --git a/testdata/past_result.json b/testdata/past_result.json index a5a11fe..ca29d35 100644 --- a/testdata/past_result.json +++ b/testdata/past_result.json @@ -1,5 +1,5 @@ { - "page_links": { + "broken_links": { "http://127.0.0.1:11836/page2": [ { "link": "http://127.0.0.1:11836/", |
