diff options
Diffstat (limited to 'brokenlinks/worker.go')
| -rw-r--r-- | brokenlinks/worker.go | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/brokenlinks/worker.go b/brokenlinks/worker.go index 387cc05..79ae796 100644 --- a/brokenlinks/worker.go +++ b/brokenlinks/worker.go @@ -89,8 +89,10 @@ func newWorker(opts Options) (wrk *worker, err error) { } wrk.baseUrl = &url.URL{ - Scheme: wrk.opts.scanUrl.Scheme, - Host: wrk.opts.scanUrl.Host, + Scheme: wrk.opts.scanUrl.Scheme, + Host: wrk.opts.scanUrl.Host, + Path: `/`, + RawPath: `/`, } if opts.PastResultFile == "" { @@ -304,8 +306,6 @@ func (wrk *worker) scan(linkq jarink.Link) (resultq map[string]jarink.Link) { return resultq } - var parentUrl *url.URL - // Check and get the redirect location or use the original URL. location := httpResp.Header.Get(`Location`) if location == `` { @@ -314,6 +314,7 @@ func (wrk *worker) scan(linkq jarink.Link) (resultq map[string]jarink.Link) { linkq.Url = location } + var parentUrl *url.URL parentUrl, err = url.Parse(location) if err != nil { linkq.StatusCode = StatusBadLink @@ -415,6 +416,7 @@ func (wrk *worker) processLink(parentUrl *url.URL, val string, kind int) ( linkq = &jarink.Link{ ParentUrl: parentUrl, + Value: val, Kind: kind, } @@ -452,7 +454,7 @@ func (wrk *worker) processLink(parentUrl *url.URL, val string, kind int) ( // "parent/page.ext" + "val" => "parent/val" tmp, _ := url.Parse(parentUrl.String()) tmp.Path = path.Dir(tmp.Path) - linkq.Url = parentUrl.JoinPath(tmp.Path).String() + linkq.Url = tmp.JoinPath(val).String() } return linkq } |
