@toantranmei/mei-nuxt3-fetcher
Version:
Minimal Nuxt 3 Module Starter.
13 lines (12 loc) • 327 B
JavaScript
import { parseURL } from "ufo";
export function getOriginAndPathnameFromURL(url) {
const { protocol, host, pathname } = parseURL(url);
let origin;
if (host && protocol)
origin = `${protocol}//${host}`;
const pathname_ = pathname.length > 0 ? pathname : void 0;
return {
origin,
pathname: pathname_
};
}