Guided Notes

Path & URL Modules

Joining and resolving paths, extracting names and extensions, parsing URLs and query strings with the WHATWG URL API.

The path module

Slide 1 / 4

Windows uses backslashes (C:\data\file.txt), Linux and macOS use forward slashes. The path module handles the differences: • path.join("data", "2025", "report.csv") → data/2025/report.csv (or data\2025\report.csv on Windows) • path.resolve("data") → absolute path from the current working directory • path.basename("/a/b/report.csv") → report.csv • path.extname("report.csv") → .csv • path.dirname("/a/b/report.csv") → /a/b • path.parse(p) → { root, dir, base, name, ext }

← The File System Module