aboutsummaryrefslogtreecommitdiff
path: root/brokenlinks/worker.go
diff options
context:
space:
mode:
Diffstat (limited to 'brokenlinks/worker.go')
-rw-r--r--brokenlinks/worker.go18
1 files changed, 3 insertions, 15 deletions
diff --git a/brokenlinks/worker.go b/brokenlinks/worker.go
index 8f278a8..94be90b 100644
--- a/brokenlinks/worker.go
+++ b/brokenlinks/worker.go
@@ -7,7 +7,6 @@ import (
"crypto/tls"
"encoding/json"
"errors"
- "fmt"
"log"
"net"
"net/http"
@@ -42,9 +41,6 @@ type worker struct {
// links or image.
baseUrl *url.URL
- // The URL to scan.
- scanUrl *url.URL
-
log *log.Logger
httpc *http.Client
@@ -83,17 +79,9 @@ func newWorker(opts Options) (wrk *worker, err error) {
},
}
- wrk.scanUrl, err = url.Parse(opts.Url)
- if err != nil {
- return nil, fmt.Errorf(`invalid URL %q`, opts.Url)
- }
- wrk.scanUrl.Path = strings.TrimSuffix(wrk.scanUrl.Path, `/`)
- wrk.scanUrl.Fragment = ""
- wrk.scanUrl.RawFragment = ""
-
wrk.baseUrl = &url.URL{
- Scheme: wrk.scanUrl.Scheme,
- Host: wrk.scanUrl.Host,
+ Scheme: wrk.opts.scanUrl.Scheme,
+ Host: wrk.opts.scanUrl.Host,
}
if opts.PastResultFile == "" {
@@ -129,7 +117,7 @@ func (wrk *worker) scanAll() (result *Result, err error) {
// Scan the first URL to make sure that the server is reachable.
var firstLinkq = linkQueue{
parentUrl: nil,
- url: wrk.scanUrl.String(),
+ url: wrk.opts.scanUrl.String(),
status: http.StatusProcessing,
}
wrk.seenLink[firstLinkq.url] = http.StatusProcessing