strip-filename.ts 253 B

12345678
  1. /**
  2. * Removes everything after the last "/", but leaves the slash.
  3. */
  4. export default function stripFilename(path: string | undefined | null): string {
  5. if (!path) return '';
  6. const index = path.lastIndexOf('/');
  7. return path.slice(0, index + 1);
  8. }