url
Parses the request URL into pathname, parsed query parameters, and the
raw search string. Uses a fast single-pass parser (indexOf + slice)
instead of the URL constructor for performance. Multi-value query
parameters automatically become arrays.
Pipeline stage: Negotiation
Import
Section titled “Import”import { url } from "@centralping/ergo";Options
Section titled “Options”None. The url() factory takes no parameters.
Return Value
Section titled “Return Value”Returns a URL descriptor stored at acc.url:
{ pathname: "/users", search: "?page=1&filter=a&filter=b", query: { page: "1", filter: ["a", "b"] }}| Property | Type | Description |
|---|---|---|
pathname | string | undefined | URL path before the query string |
search | string | undefined | Raw query string including leading ?; undefined when absent |
query | Record<string, string | string[]> | Parsed query parameters; multi-value keys become arrays |
queryuses a null-prototype object to prevent prototype pollution- Bounded by
maxPairs: 256andmaxQueryLength: 8192defaults
Error Responses
Section titled “Error Responses”None.
import { compose, url } from "@centralping/ergo";
const pipeline = compose( {fn: url(), setPath: "url"}, (req, res, acc) => ({ response: { body: { path: acc.url.pathname, page: acc.url.query.page, }, }, }),);// ergo-router automatically includes URL parsing.// acc.url.query is available in your execute handler.
router.get("/articles", { execute: (req, res, acc) => ({ response: { body: queryArticles({ page: acc.url.query.page, filter: acc.url.query.filter, }), }, }),});API Reference
Section titled “API Reference”See the auto-generated url API docs.