Readme

Val Express URL

Returns the Express URL of the val it's called in

Example usage

function testThisExpressUrl(req, res) { let url = @stevekrouse.thisExpressURL(); res.send(`<a href="${url}">${url}</a>`); }

Source: https://www.val.town/v/stevekrouse.testThisExpressUrl

Output: https://stevekrouse-testThisExpressUrl.express.val.run

1
2
3
4
5
6
7
8
export const thisExpressURL = () => {
let { valName, userHandle } =
new Error().stack.match(/@@({.+?})@@/g).map((e) =>
JSON.parse(e.slice(2, -2))
)[1];
return `https://${userHandle}-${valName}.express.val.run`;
};
// Forked from @easrng.thisReference
Val Town is a social website to write and deploy JavaScript.
Build APIs and schedule functions from your browser.
Comments
Nobody has commented on this val yet: be the first!
October 23, 2023