Something went wrong. Try again.
Self-hosted file management and sharing system, supports multiple storage providers. forked from tdvorak.tngl.sh/cloudreve
Something went wrong. Try again.
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879import { formatTimestamps } from "./timezone.js";import { displayPath } from "../paths.js";import { renderHuman } from "./human.js";import { browserLink, webLocations, type WebContext } from "./links.js";
export { safe } from "./safe.js";
import { safe } from "./safe.js";
export function entry(value: { id: string; name: string; path: string; type: number; size: number;}): unknown { return { ...(safe(value) as object), name: value.name, displayPath: displayPath(value.path), };}
export function format( data: unknown, json: boolean, revealPassword = false, discloseUrls = false, timezone?: string, options: WebContext & { command?: string; args?: string[]; width?: number; color?: boolean; } = {},): string { let output = safe(data ?? null, discloseUrls);
if ( revealPassword && data && typeof data === "object" && "password" in data && typeof data.password === "string" ) { output = { ...(output as object), password: data.password }; }
if (!json) { const file = output as { path?: unknown; type?: number; id?: string; metadata?: Record<string, unknown>; } | null;
const target = file?.metadata?.["sys:shared_redirect"] ?? file?.path;
const browser = file && typeof target === "string" ? browserLink(target, options, file) : undefined;
output = webLocations(formatTimestamps(output, timezone ?? "UTC"), options);
if (browser) { output = { ...(output as object), browser }; } }
return json ? `${JSON.stringify({ schemaVersion: 1, data: output })}\n` : data === undefined && !options.command ? "" : renderHuman(options.command ?? "", output, { ...options, timezone: timezone ?? "UTC", args: webLocations(safe(options.args ?? []), options) as string[], });}