Skip to content

Commit

Permalink
Feature/release 1.7.7 (#94)
Browse files Browse the repository at this point in the history
* fixes #93

* dependencies up
  • Loading branch information
s0rg authored Aug 5, 2024
1 parent 2b540f1 commit 6522644
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 11 deletions.
4 changes: 2 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@ go 1.22
require (
github.com/s0rg/compflag v1.1.0
github.com/s0rg/set v1.2.0
github.com/tdewolff/parse/v2 v2.7.14
golang.org/x/net v0.26.0
github.com/tdewolff/parse/v2 v2.7.15
golang.org/x/net v0.27.0
)
8 changes: 4 additions & 4 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ github.com/s0rg/compflag v1.1.0 h1:xhCUPLy+5Ue/Q9I/nIcLti2Ul6P42JYx4UvtYoDXmlQ=
github.com/s0rg/compflag v1.1.0/go.mod h1:XMntVpc3+jpmBe0s8xo4w9swH8T9ARGkMC9HFiDRoUw=
github.com/s0rg/set v1.2.0 h1:53b207YMktNQJXYei/oHuTR5oOO2e9+eieZOncYsh9g=
github.com/s0rg/set v1.2.0/go.mod h1:xz3nDbjF4nyMLvAHvmE7rigXpNrKKTsi6iANznIB1/4=
github.com/tdewolff/parse/v2 v2.7.14 h1:100KJ+QAO3PpMb3uUjzEU/NpmCdbBYz6KPmCIAfWpR8=
github.com/tdewolff/parse/v2 v2.7.14/go.mod h1:3FbJWZp3XT9OWVN3Hmfp0p/a08v4h8J9W1aghka0soA=
github.com/tdewolff/parse/v2 v2.7.15 h1:hysDXtdGZIRF5UZXwpfn3ZWRbm+ru4l53/ajBRGpCTw=
github.com/tdewolff/parse/v2 v2.7.15/go.mod h1:3FbJWZp3XT9OWVN3Hmfp0p/a08v4h8J9W1aghka0soA=
github.com/tdewolff/test v1.0.11-0.20231101010635-f1265d231d52 h1:gAQliwn+zJrkjAHVcBEYW/RFvd2St4yYimisvozAYlA=
github.com/tdewolff/test v1.0.11-0.20231101010635-f1265d231d52/go.mod h1:6DAvZliBAAnD7rhVgwaM7DE5/d9NMOAJ09SqYqeK4QE=
golang.org/x/net v0.26.0 h1:soB7SVo0PWrY4vPW/+ay0jKDNScG2X9wFeYlXIvJsOQ=
golang.org/x/net v0.26.0/go.mod h1:5YKkiSynbBIh3p6iOc/vibscux0x38BZDkn8sCUPxHE=
golang.org/x/net v0.27.0 h1:5K3Njcw06/l2y9vpGCSdcxWOYHOUk3dVNGDXN+FvAys=
golang.org/x/net v0.27.0/go.mod h1:dDi0PyhWNoiUOrAS8uXv/vnScO4wnHQO4mj9fn/RytE=
13 changes: 8 additions & 5 deletions internal/crawler/crawler.go
Original file line number Diff line number Diff line change
Expand Up @@ -322,17 +322,20 @@ func (c *Crawler) process(
}

handleStatic := func(s string) {
var ok bool

switch {
case strings.HasPrefix(s, doubleDash):
s = base.Scheme + s
s, ok = base.Scheme+s, true
case strings.Contains(s, doubleDash):
ok = true
default:
b, _ := url.Parse(uri)
r, _ := url.Parse(s)
s = b.ResolveReference(r).String()
s, ok = resolveRef(uri, s)
}

c.staticHandler(s)
if ok {
c.staticHandler(s)
}
}

content := hdrs.Get(contentType)
Expand Down
16 changes: 16 additions & 0 deletions internal/crawler/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -225,3 +225,19 @@ func urlhash(s string) (rv uint64) {

return hash.Sum64()
}

func resolveRef(base, uri string) (rv string, ok bool) {
b, err := url.Parse(base)
if err != nil {
return
}

u, err := url.Parse(uri)
if err != nil {
return
}

rv = b.ResolveReference(u).String()

return rv, true
}

0 comments on commit 6522644

Please sign in to comment.