UNPKG

compare-path

Version:

An easy-to-use package to detect if two URLs match each other by comparing their abstract paths

19 lines 581 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.cleanPath = void 0; /** * Cleans a URL path by: * * - Trimming leading and trailing whitespace * - Removing leading and trailing slashes * - Replacing multiple consecutive slashes with a single slash * * @param path - The raw path string (e.g., '///users//1///') * @returns The cleaned path (e.g., 'users/1') */ const cleanPath = (path) => path .trim() .replace(/^\/+|\/+$/g, '') .replace(/\/{2,}/g, '/'); exports.cleanPath = cleanPath; //# sourceMappingURL=clean-path.js.map