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

Function AddLocalHostOrDomainIs

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

Source from the content-addressed store, hash-verified

33}
34
35func AddLocalHostOrDomainIs(vm *goja.Runtime) error {
36 return vm.GlobalObject().Set("localHostOrDomainIs", func(call goja.FunctionCall) goja.Value {
37 if len(call.Arguments) < 2 {
38 return vm.ToValue(false)
39 }
40 host := strings.ToLower(call.Argument(0).String())
41 domain := strings.ToLower(call.Argument(1).String())
42 if host == domain {
43 return vm.ToValue(true)
44 }
45 if strings.Contains(host, ".") {
46 return vm.ToValue(false)
47 }
48 return vm.ToValue(strings.HasPrefix(domain, host+"."))
49 })
50}
51
52func AddDNSDomainLevels(vm *goja.Runtime) error {
53 return vm.GlobalObject().Set("dnsDomainLevels", 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