MCPcopy Index your code
hub / github.com/tinyhttp/tinyhttp / getSubdomains

Function getSubdomains

packages/app/src/request.ts:64–72  ·  view source on GitHub ↗
(req: Request, subdomainOffset = 2)

Source from the content-addressed store, hash-verified

62 all(req, trustRemoteAddress(req))
63
64export const getSubdomains = (req: Request, subdomainOffset = 2): string[] => {
65 const hostname = getHostname(req)
66
67 if (!hostname) return []
68
69 const subdomains = isIP(hostname) ? [hostname] : hostname.split('.').reverse()
70
71 return subdomains.slice(subdomainOffset)
72}
73
74export type Connection = IncomingMessage['socket'] & {
75 encrypted: boolean

Callers 1

extendMiddlewareFunction · 0.90

Calls 1

getHostnameFunction · 0.85

Tested by

no test coverage detected