Fix stripProtocol

This commit is contained in:
Adria Navarro 2024-02-01 12:20:31 +01:00
parent d1cf13707d
commit 1439eb9b27
2 changed files with 15 additions and 1 deletions

View File

@ -70,6 +70,15 @@ export function init() {
)
)
global.setSync(
"helpersStripProtocol",
new ivm.Callback((str: string) => {
var parsed = url.parse(str) as any
parsed.protocol = ""
return parsed.format()
})
)
const helpersModule = jsIsolate.compileModuleSync(
`${injectedRequire};${helpersSource}`
)

View File

@ -1,3 +1,8 @@
const { getJsHelperList } = require("./helpers/list")
module.exports = getJsHelperList()
const helpers = getJsHelperList()
module.exports = {
...helpers,
// point stripProtocol to a unexisting function to be able to declare it on isolated-vm
stripProtocol: helpersStripProtocol,
}