UNPKG

tezx

Version:

TezX is a high-performance, lightweight JavaScript framework designed for speed, scalability, and flexibility. It enables efficient routing, middleware management, and static file serving with minimal configuration. Fully compatible with Node.js, Deno, an

31 lines (30 loc) 820 B
function normalizePath(path) { return ("/" + path.replace(/\\/g, "").replace(/\/+/g, "/").replace(/^\/+/, "")); } export function sanitizePathSplit(basePath, path) { const parts = `${basePath}/${path}` .replace(/\\/g, "") .replace(/\/+/g, "/") ?.split("/") .filter(Boolean); return parts; } export const wildcardOrOptionalParamRegex = /\/\*|:[^/]+[?*]/; export function urlParse(url) { let u = URL.parse(url); let query = {}; if (u?.search) { new URLSearchParams(u?.search).forEach((value, key) => { query[key] = value; }); } return { pathname: u?.pathname, query: query, protocol: u?.protocol, origin: u?.origin, hostname: u?.hostname, href: url, port: u?.port, }; }