20 lines · 761 B · TypeScript
RawDownload
import os from "node:os";import path from "node:path"; // We read the raw input field, so expand a leading ~ ourselves (~\ too, for// paths pasted from Windows). ~bob isn't us, so leave it alone.export function expandHome(input: string, home: string = os.homedir()): string {  const trimmed = input.trim();  if (trimmed === "~") return home;  if (trimmed.startsWith("~/") || trimmed.startsWith("~\\")) {    return path.join(home, trimmed.slice(2));  }  return trimmed;} // Typed input -> a path for fs.mkdir. Blank returns "" (caller: leave it be).export function normalizeDownloadDir(input: string, home: string = os.homedir()): string {  const expanded = expandHome(input, home);  if (!expanded) return "";  return path.normalize(expanded);}

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t