mirror of
https://github.com/wukko/cobalt.git
synced 2024-11-15 04:39:58 +00:00
url: only export functions that are used externally
This commit is contained in:
parent
ae91f8b120
commit
c1958596e9
1 changed files with 10 additions and 11 deletions
|
@ -2,7 +2,7 @@ import { services } from "../config.js";
|
|||
import { strict as assert } from "node:assert";
|
||||
import psl from "psl";
|
||||
|
||||
export function aliasURL(url) {
|
||||
function aliasURL(url) {
|
||||
assert(url instanceof URL);
|
||||
|
||||
const host = psl.parse(url.hostname);
|
||||
|
@ -75,7 +75,7 @@ export function aliasURL(url) {
|
|||
return url
|
||||
}
|
||||
|
||||
export function cleanURL(url) {
|
||||
function cleanURL(url) {
|
||||
assert(url instanceof URL);
|
||||
const host = psl.parse(url.hostname).sld;
|
||||
let stripQuery = true;
|
||||
|
@ -103,15 +103,7 @@ export function cleanURL(url) {
|
|||
return url
|
||||
}
|
||||
|
||||
export function normalizeURL(url) {
|
||||
return cleanURL(
|
||||
aliasURL(
|
||||
new URL(url.replace(/^https\/\//, 'https://'))
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
export function getHostIfValid(url) {
|
||||
function getHostIfValid(url) {
|
||||
const host = psl.parse(url.hostname);
|
||||
if (host.error) return;
|
||||
|
||||
|
@ -126,6 +118,13 @@ export function getHostIfValid(url) {
|
|||
return host.sld;
|
||||
}
|
||||
|
||||
export function normalizeURL(url) {
|
||||
return cleanURL(
|
||||
aliasURL(
|
||||
new URL(url.replace(/^https\/\//, 'https://'))
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
export function extract(url) {
|
||||
const host = getHostIfValid(url);
|
||||
|
|
Loading…
Reference in a new issue