"use strict";
/*
 *  This file is part of CoCalc: Copyright © 2020 Sagemath, Inc.
 *  License: AGPLv3 s.t. "Commons Clause" – see LICENSE.md for details
 */
Object.defineProperty(exports, "__esModule", { value: true });
exports.getTitle = exports.trunc = exports.isSha1Hash = exports.isUUID = exports.containingPath = exports.getExtension = void 0;
var path_1 = require("path");
var misc_1 = require("@cocalc/util/misc");
Object.defineProperty(exports, "getExtension", { enumerable: true, get: function () { return misc_1.getExtension; } });
Object.defineProperty(exports, "containingPath", { enumerable: true, get: function () { return misc_1.containingPath; } });
function isUUID(s) {
    // todo: add full check.
    return typeof s == "string" && s.length == 36;
}
exports.isUUID = isUUID;
function isSha1Hash(s) {
    return typeof s == "string" && s.length == 40;
    // todo: could add full check (i.e., each character is in 0-e)
}
exports.isSha1Hash = isSha1Hash;
function trunc(s, n) {
    return s.length > n ? s.slice(0, n - 1) + "…" : s;
}
exports.trunc = trunc;
function getTitle(_a) {
    var path = _a.path, relativePath = _a.relativePath;
    var b = (0, path_1.basename)(relativePath);
    return b ? b : (0, path_1.basename)(path);
}
exports.getTitle = getTitle;
//# sourceMappingURL=util.js.map