diff --git a/src/url.ts b/src/url.ts index c1276675..bfc1b7fa 100644 --- a/src/url.ts +++ b/src/url.ts @@ -9,6 +9,9 @@ import { encodeHost, } from "./encoding"; +/** + * @deprecated use native URL with `new URL(input)` or `ufo.parseURL(input)` + */ export class $URL implements URL { protocol: string; host: string; @@ -136,3 +139,10 @@ export class $URL implements URL { return this.href; } } + +/** + * @deprecated use native URL with `new URL(input)` or `ufo.parseURL(input)` + */ +export function createURL(input: string): $URL { + return new $URL(input); +} diff --git a/src/utils.ts b/src/utils.ts index 183e70eb..ee9dc7b1 100644 --- a/src/utils.ts +++ b/src/utils.ts @@ -1,4 +1,4 @@ -import { $URL } from "./url"; +import { createURL } from "./url"; import { parseURL, stringifyParsedURL } from "./parse"; import { QueryObject, parseQuery, stringifyQuery, ParsedQuery } from "./query"; import { decode } from "./encoding"; @@ -211,13 +211,8 @@ export function withProtocol(input: string, protocol: string): string { return protocol + input.slice(match[0].length); } -// $URL based utils - -export function createURL(input: string): $URL { - return new $URL(input); -} - export function normalizeURL(input: string): string { + // TODO: remove dependecny on createURL return createURL(input).toString(); }