Path: blob/master/src/packages/next/lib/share/util.ts
1449 views
/*1* This file is part of CoCalc: Copyright © 2020 Sagemath, Inc.2* License: MS-RSL – see LICENSE.md for details3*/45import { basename } from "path";6export { getExtension, containingPath } from "@cocalc/util/misc";78export function isUUID(s: string): boolean {9// todo: add full check.10return typeof s == "string" && s.length == 36;11}1213export function isSha1Hash(s: string): boolean {14return typeof s == "string" && s.length == 40;15// todo: could add full check (i.e., each character is in 0-e)16}1718export function trunc(s: string, n: number): string {19return s.length > n ? s.slice(0, n - 1) + "…" : s;20}2122export function getTitle({23path,24relativePath,25}: {26path: string;27relativePath: string;28}): string {29const b = basename(relativePath);30return b ? b : basename(path);31}323334