diff --git a/common/space_lua/stdlib/space_lua.ts b/common/space_lua/stdlib/space_lua.ts index 422707b1..4e3cfdce 100644 --- a/common/space_lua/stdlib/space_lua.ts +++ b/common/space_lua/stdlib/space_lua.ts @@ -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; + } + }, + ), });