Compare commits

...
4 changed files with 22 additions and 5 deletions

No files matched your search

-4
View File
@@ -23,10 +23,6 @@ filippo.io/edwards25519 v1.0.0-rc.1 h1:m0VOOB23frXZvAOK44usCgLWvtsxIoMCTBGJZlpmG
filippo.io/edwards25519 v1.0.0-rc.1/go.mod h1:N1IkdkCkiLB6tki+MYJoSx2JTY9NUlxZE7eHn5EwJns=
github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo=
github.com/GopeedLab/webview_go v0.0.0-20260416010719-fc58e7d53769 h1:iuMR7aHvckis8PKYUDXDa8elcmf34GksWpaYak1EYKw=
github.com/GopeedLab/webview_go v0.0.0-20260416010719-fc58e7d53769/go.mod h1:FvV19lu9rQ9NcbczN5y8pbWecURRRbWa8tbfFARBDa0=
github.com/GopeedLab/webview_go v0.0.0-20260423023243-b3f067ccab2f h1:yu//jtofUpHZB+IpB1xIH8z4o4JsFJ6pMvgA1Ww/ElY=
github.com/GopeedLab/webview_go v0.0.0-20260423023243-b3f067ccab2f/go.mod h1:FvV19lu9rQ9NcbczN5y8pbWecURRRbWa8tbfFARBDa0=
github.com/GopeedLab/webview_go v0.0.0-20260423085439-7a2f88b6e9b5 h1:86LVTaNDM/j/uTAD2HedkXNO9LIQlt642VAdbU/0D/M=
github.com/GopeedLab/webview_go v0.0.0-20260423085439-7a2f88b6e9b5/go.mod h1:FvV19lu9rQ9NcbczN5y8pbWecURRRbWa8tbfFARBDa0=
github.com/Masterminds/semver/v3 v3.2.1 h1:RN9w6+7QoMeJVGyfmbcgs28Br8cvmnucEXnY0rYXWg0=
+3
View File
@@ -426,6 +426,9 @@ func ensureResourceRequestRawURLs(parentReq *base.Request, res *base.Resource) {
}
func (d *Downloader) Resolve(req *base.Request, opts *base.Options) (rr *ResolveResult, err error) {
if req == nil {
return nil, errors.New("request cannot be nil")
}
rrId, err := gonanoid.New()
if err != nil {
return
+1 -1
View File
@@ -548,7 +548,7 @@ func (s *Script) match(event ActivationEvent, req *base.Request) bool {
if s.Event != string(event) {
return false
}
if s.Match == nil || (len(s.Match.Urls) == 0 && len(s.Match.Labels) == 0) {
if req == nil || s.Match == nil || (len(s.Match.Urls) == 0 && len(s.Match.Labels) == 0) {
return false
}
+18
View File
@@ -21,6 +21,24 @@ import (
"github.com/dop251/goja"
)
func TestDownloader_ResolveNilRequest(t *testing.T) {
setupDownloader(func(downloader *Downloader) {
if _, err := downloader.Resolve(nil, nil); err == nil {
t.Fatal("expected invalid request error")
}
})
}
func TestScript_MatchNilRequest(t *testing.T) {
script := &Script{
Event: string(EventOnResolve),
Match: &Match{Urls: []string{"*://*/*"}},
}
if script.match(EventOnResolve, nil) {
t.Fatal("expected nil request not to match")
}
}
func TestDownloader_InstallExtensionByFolder(t *testing.T) {
setupDownloader(func(downloader *Downloader) {
if _, err := downloader.InstallExtensionByFolder("./testdata/extensions/basic", false); err != nil {