Skip to content

Commit

Permalink
refactor: deprecate $URL and createURL
Browse files Browse the repository at this point in the history
  • Loading branch information
pi0 committed Feb 5, 2024
1 parent 11404da commit f1af9b3
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 7 deletions.
10 changes: 10 additions & 0 deletions src/url.ts
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
}
9 changes: 2 additions & 7 deletions 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";
Expand Down Expand Up @@ -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();
}

Expand Down

0 comments on commit f1af9b3

Please sign in to comment.