-
-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathnormalize.ts
More file actions
16 lines (14 loc) · 564 Bytes
/
normalize.ts
File metadata and controls
16 lines (14 loc) · 564 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
import { requireNonEmptyString } from "../../lang";
import { join } from "./join";
/**
* Normalizes a URL path, bringing it to a standard, absolute form.
*
* @param {string} path - The original URL path string to normalize.
* @returns {string} A new string representing the normalized, absolute, and URL-encoded path.
* @throws {@link EmptyStringException}
* @environment `Google Apps Script`, `Browser`
*/
export function normalize(path: string): string {
const result = requireNonEmptyString(path);
return join("/", result.trim());
}