MCPcopy Create free account
hub / github.com/SenseUnit/dumbproxy / AddDNSDomainIs

Function AddDNSDomainIs

jsext/hostutil.go:18–33  ·  view source on GitHub ↗
(vm *goja.Runtime)

Source from the content-addressed store, hash-verified

16}
17
18func AddDNSDomainIs(vm *goja.Runtime) error {
19 return vm.GlobalObject().Set("dnsDomainIs", func(call goja.FunctionCall) goja.Value {
20 if len(call.Arguments) < 2 {
21 return vm.ToValue(false)
22 }
23 host := strings.ToLower(call.Argument(0).String())
24 domain := strings.ToLower(call.Argument(1).String())
25 if host == domain {
26 return vm.ToValue(true)
27 }
28 if !strings.HasPrefix(domain, ".") {
29 domain = "." + domain
30 }
31 return vm.ToValue(strings.HasSuffix(host, domain))
32 })
33}
34
35func AddLocalHostOrDomainIs(vm *goja.Runtime) error {
36 return vm.GlobalObject().Set("localHostOrDomainIs", func(call goja.FunctionCall) goja.Value {

Callers

nothing calls this directly

Calls 2

SetMethod · 0.45
StringMethod · 0.45

Tested by

no test coverage detected