1
0
Fork 0

Adding upstream version 0.0~git20250409.f7acab6.

Signed-off-by: Daniel Baumann <daniel@debian.org>
This commit is contained in:
Daniel Baumann 2025-05-22 11:36:18 +02:00
parent b9b5d88025
commit 21b930d007
Signed by: daniel
GPG key ID: FBB4F0E80A80222F
51 changed files with 11229 additions and 0 deletions

36
url/module.go Normal file
View file

@ -0,0 +1,36 @@
package url
import (
"github.com/dop251/goja"
"github.com/dop251/goja_nodejs/require"
)
const ModuleName = "url"
type urlModule struct {
r *goja.Runtime
URLSearchParamsPrototype *goja.Object
URLSearchParamsIteratorPrototype *goja.Object
}
func Require(runtime *goja.Runtime, module *goja.Object) {
exports := module.Get("exports").(*goja.Object)
m := &urlModule{
r: runtime,
}
exports.Set("URL", m.createURLConstructor())
exports.Set("URLSearchParams", m.createURLSearchParamsConstructor())
exports.Set("domainToASCII", m.domainToASCII)
exports.Set("domainToUnicode", m.domainToUnicode)
}
func Enable(runtime *goja.Runtime) {
m := require.Require(runtime, ModuleName).ToObject(runtime)
runtime.Set("URL", m.Get("URL"))
runtime.Set("URLSearchParams", m.Get("URLSearchParams"))
}
func init() {
require.RegisterCoreModule(ModuleName, Require)
}