INNER CODE UNIT · JavaScript
resolvePathname
iamlukethedev/Hermes3D · server/index.js:17
const resolvePathname = (url) => {
const raw = typeof url === "string" ? url : "";
const idx = raw.indexOf("?");
return (idx === -1 ? raw : raw.slice(0, idx)) || "/";
};
const CERT_DIR = require("node:path").join(__dirname, "..", ".certs");
const CERT_PATH = require("node:path").join(CERT_DIR, "localhost.crt");
const KEY_PATH = require("node:path").join(CERT_DIR, "localhost.key");
const generateHttpsCert = async () => {
const fs = require("node:fs");
// Re-use a saved cert so the browser only needs to trust it once.
if (fs.existsSync(CERT_PATH) && fs.existsSync(KEY_PATH)) {
return {
key: fs.readFileSync(KEY_PATH, "utf8"),
cert: fs.readFileSync(CERT_PATH, "utf8"),