From f1af9b3a5b2d93e55506c7eecb28bb3ad051a7e8 Mon Sep 17 00:00:00 2001 From: Pooya Parsa Date: Mon, 5 Feb 2024 17:50:07 +0100 Subject: [PATCH] refactor: deprecate `$URL` and `createURL` --- src/url.ts | 10 ++++++++++ src/utils.ts | 9 ++------- 2 files changed, 12 insertions(+), 7 deletions(-) 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(); }