evalstate's picture
download
raw
604 Bytes
export function isBrowser(headers: Record<string, string | string[] | undefined>): boolean {
const acceptHeader = headers['accept'];
if (!acceptHeader) {
return false;
}
const accept = Array.isArray(acceptHeader) ? acceptHeader.join(',') : acceptHeader;
// If accept contains text/event-stream or application/json, it's not a browser
if (accept.includes('text/event-stream') || accept.includes('application/json')) {
return false;
}
// If accept contains */* it's likely a browser
if (accept.includes('*/*')) {
return true;
}
// Otherwise assume it's not a browser
return false;
}

Xet Storage Details

Size:
604 Bytes
·
Xet hash:
fb5548d3d75394b6249f603d5ceb46b13f2aca17b668cf11c783148f4fed6d1a

Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.