26 lines
744 B
TypeScript
26 lines
744 B
TypeScript
|
|
type URLInit = {
|
||
|
|
protocol: string;
|
||
|
|
host: string;
|
||
|
|
pathname: string;
|
||
|
|
search: string;
|
||
|
|
};
|
||
|
|
/**
|
||
|
|
* URL wrapper with fast paths to access to the following props:
|
||
|
|
*
|
||
|
|
* - `url.pathname`
|
||
|
|
* - `url.search`
|
||
|
|
* - `url.searchParams`
|
||
|
|
* - `url.protocol`
|
||
|
|
*
|
||
|
|
* **NOTES:**
|
||
|
|
*
|
||
|
|
* - It is assumed that the input URL is **already encoded** and formatted from an HTTP request. A fragment (`#`), while not valid in an origin-form request target, is handled via full URL parsing.
|
||
|
|
* - Triggering the setters or getters on other props will deoptimize to full URL parsing.
|
||
|
|
* - Changes to `searchParams` will be discarded as we don't track them.
|
||
|
|
*/
|
||
|
|
declare const FastURL: {
|
||
|
|
new (url: string | URLInit): URL & {
|
||
|
|
_url: URL;
|
||
|
|
};
|
||
|
|
};
|
||
|
|
export { FastURL };
|