get-host-type
v1.0.1
Published
Tiny utility to detect a host environment.
Downloads
200
Readme
getHostType
Tiny utility to detect a host environment.
Usage
import { getHostType } from "get-host-type";
const host = getHostType("admin123.example.com");
console.log(host);
// Example output:
// {
// kind: "tenant-subdomain",
// hostname: "admin123.example.com",
// subdomain: "admin123",
// registrableDomain: "example.com",
// }Options
getHostType(hostHeader, options?) supports:
reservedSubdomains: list of subdomains to classify asreserved-subdomaininstead oftenant-subdomain.validHosts: list passed totldtsso non-standard hosts (likelocalhost) are treated as valid.
import { getHostType } from "get-host-type";
const host = getHostType("admin.example.com", {
reservedSubdomains: ["admin", "www"],
validHosts: ["localhost"],
});
// Example output:
// {
// kind: "reserved-subdomain",
// hostname: "admin.example.com",
// subdomain: "admin",
// registrableDomain: "example.com",
// }Development
pnpm test