@cocalc/backend
Version:
CoCalc backend functionality: functionality used by either the hub, the next.js server or the project.
17 lines • 648 B
JavaScript
;
// Any non-absolute path is assumed to be relative to the user's home directory.
// This function converts such a path to an absolute path.
Object.defineProperty(exports, "__esModule", { value: true });
const path_1 = require("path");
function abspath(path) {
if (path.length === 0) {
return process.env.HOME ?? "";
}
if (path.startsWith("/")) {
return path; // already an absolute path
}
// The regexp is to get rid of /./, which is the same as /...
return (0, path_1.join)(process.env.HOME ?? "", path).replace(/\/\.\//g, "/");
}
exports.default = abspath;
//# sourceMappingURL=abspath.js.map