aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorShulhan <ms@kilabit.info>2026-02-12 01:05:52 +0700
committerShulhan <ms@kilabit.info>2026-02-12 01:07:04 +0700
commite4b3383d84cd181f4a9fec1097ec61e583d6f827 (patch)
tree1ff82ca5f74f854cb4f5d2601e382cd2705c99eb
parent9c7ee77376294e9abd70ca356e26d0ab16ad7466 (diff)
downloadjarink-e4b3383d84cd181f4a9fec1097ec61e583d6f827.tar.xz
brokenlinks: fix possible panic in markAsBroken
If the Link does not have parentUrl, set the parent URL using the link URL itself. This only happened if the target URL that we will scan return an error.
-rw-r--r--brokenlinks/worker.go7
1 files changed, 6 insertions, 1 deletions
diff --git a/brokenlinks/worker.go b/brokenlinks/worker.go
index 79ae796..ce109ed 100644
--- a/brokenlinks/worker.go
+++ b/brokenlinks/worker.go
@@ -245,7 +245,12 @@ func (wrk *worker) markAsBroken(linkq jarink.Link) {
if slices.Contains(wrk.opts.ignoreStatus, linkq.StatusCode) {
return
}
- var parentUrl = linkq.ParentUrl.String()
+ var parentUrl string
+ if linkq.ParentUrl == nil {
+ parentUrl = linkq.Url
+ } else {
+ parentUrl = linkq.ParentUrl.String()
+ }
var listBroken = wrk.result.BrokenLinks[parentUrl]
if linkq.ErrScan != nil {
linkq.Error = linkq.ErrScan.Error()