diff --git a/packages/server/src/jsRunner/index.ts b/packages/server/src/jsRunner/index.ts index b7e63ce63c..8e529d533d 100644 --- a/packages/server/src/jsRunner/index.ts +++ b/packages/server/src/jsRunner/index.ts @@ -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}` ) diff --git a/packages/string-templates/src/index-helpers.js b/packages/string-templates/src/index-helpers.js index 3c16a352fc..b0d9ac5c68 100644 --- a/packages/string-templates/src/index-helpers.js +++ b/packages/string-templates/src/index-helpers.js @@ -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, +}