Expose SB instance base URL to Lua

pull/1232/head
Zef Hemel 2025-02-06 08:36:43 +01:00
parent 4f707e498c
commit 9ccfe13818
1 changed files with 13 additions and 0 deletions

View File

@ -135,4 +135,17 @@ export const spaceLuaApi = new LuaTable({
return interpolateLuaString(sf, template, envAugmentation);
},
),
/**
* Returns your SilverBullet instance's base URL, or `undefined` when run on the server
*/
base_url: new LuaBuiltinFunction(
() => {
// Deal with Deno
if (typeof location === "undefined") {
return null;
} else {
return location.protocol + "//" + location.host;
}
},
),
});