Documentation / @zerotal/core / http / UrlGenerator
Interface: UrlGenerator
Defined in: http/url.ts:93
Returned by url() (no arguments) — the URL generator surface.
Methods
is()
is(
path):boolean
Defined in: http/url.ts:95
Checks if the current URL matches a given path.
Parameters
path
string
Returns
boolean
current()
current():
string
Defined in: http/url.ts:97
The current request URL, WITHOUT the query string.
Returns
string
full()
full():
string
Defined in: http/url.ts:99
The current request URL, WITH the query string.
Returns
string
previous()
previous(
fallback?):string
Defined in: http/url.ts:101
The previous URL (the Referer header), falling back to fallback.
Parameters
fallback?
string
Returns
string
to()
to(
path,extra?,secure?):string
Defined in: http/url.ts:103
A fully-qualified URL for a path (+ optional extra path segments).
Parameters
path
string
extra?
(string | number)[]
secure?
boolean
Returns
string
secure()
secure(
path,extra?):string
Defined in: http/url.ts:105
A fully-qualified HTTPS URL.
Parameters
path
string
extra?
(string | number)[]
Returns
string
query()
query(
path,query,extra?):string
Defined in: http/url.ts:107
A fully-qualified URL with a query string appended.
Parameters
path
string
query
extra?
(string | number)[]
Returns
string
route()
route(
name,params?):string
Defined in: http/url.ts:109
A fully-qualified URL for a named route.
Parameters
name
string
params?
Record<string, string | number>
Returns
string
intended()
intended(
fallback?):string
Defined in: http/url.ts:118
The URL the user was heading to before authentication (the session's intended_url),
falling back to fallback. Cross-origin stored URLs are rejected (open-redirect guard).
Returns a plain string.
Parameters
fallback?
string
Returns
string
Example
url().intended("/dashboard");
sign()
sign(
base,params?,expiresInMinutes?,secret?):string
Defined in: http/url.ts:130
Build an HMAC-signed, time-limited URL. Signs with APP_KEY unless secret is given.
Parameters
base
string
The base URL (scheme + host + path).
params?
Record<string, string>
Extra query parameters to include (encoded into the signature).
expiresInMinutes?
number
Minutes until the link expires. Default 60.
secret?
string
Sign with this key instead of APP_KEY.
Returns
string
verify()
verify(
signedUrl,secret?):boolean
Defined in: http/url.ts:137
Verify a signed URL — false if tampered, expired, or unsigned.
Parameters
signedUrl
string
secret?
string
Returns
boolean
setSecret()
setSecret(
secret):void
Defined in: http/url.ts:139
Override the default signing secret (otherwise derived from APP_KEY).
Parameters
secret
string
Returns
void