use nullish for these

This commit is contained in:
dangered wolf 2023-09-10 11:01:20 -04:00
parent 314a413506
commit 8b66d2a715
No known key found for this signature in database
GPG key ID: 41E4D37680ED8B58

View file

@ -342,26 +342,26 @@ const versionRequest = async (request: IRequest) => {
return new Response( return new Response(
Strings.VERSION_HTML.format({ Strings.VERSION_HTML.format({
rtt: request.cf?.clientTcpRtt ? `🏓 ${request.cf.clientTcpRtt} ms RTT` : '', rtt: request.cf?.clientTcpRtt ? `🏓 ${request.cf.clientTcpRtt} ms RTT` : '',
colo: request.cf?.colo || '??', colo: request.cf?.colo ?? '??',
httpversion: request.cf?.httpProtocol || 'Unknown HTTP Version', httpversion: request.cf?.httpProtocol ?? 'Unknown HTTP Version',
tlsversion: request.cf?.tlsVersion || 'Unknown TLS Version', tlsversion: request.cf?.tlsVersion ?? 'Unknown TLS Version',
ip: ip:
request.headers.get('x-real-ip') || request.headers.get('x-real-ip') ??
request.headers.get('cf-connecting-ip') || request.headers.get('cf-connecting-ip') ??
'Unknown IP', 'Unknown IP',
// eslint-disable-next-line @typescript-eslint/ban-ts-comment // eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore - @cloudflare/workers-types v4 is missing IncomingRequestCfProperties.city despite it being a real property // @ts-ignore - @cloudflare/workers-types v4 is missing IncomingRequestCfProperties.city despite it being a real property
city: request.cf?.city || 'Unknown City', city: request.cf?.city ?? 'Unknown City',
// eslint-disable-next-line @typescript-eslint/ban-ts-comment // eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore - @cloudflare/workers-types v4 is missing IncomingRequestCfProperties.country / region despite it being a real property // @ts-ignore - @cloudflare/workers-types v4 is missing IncomingRequestCfProperties.country / region despite it being a real property
region: request.cf?.region || request.cf?.country || 'Unknown Region', region: request.cf?.region ?? request.cf?.country ?? 'Unknown Region',
// eslint-disable-next-line @typescript-eslint/ban-ts-comment // eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore - @cloudflare/workers-types v4 is missing IncomingRequestCfProperties.country despite it being a real property // @ts-ignore - @cloudflare/workers-types v4 is missing IncomingRequestCfProperties.country despite it being a real property
country: request.cf?.country || 'Unknown Country', country: request.cf?.country ?? 'Unknown Country',
asn: `AS${request.cf?.asn || '??'} (${ asn: `AS${request.cf?.asn ?? '??'} (${
request.cf?.asOrganization || 'Unknown ASN' request.cf?.asOrganization ?? 'Unknown ASN'
})`, })`,
ua: sanitizeText(request.headers.get('user-agent') || 'Unknown User Agent') ua: sanitizeText(request.headers.get('user-agent') ?? 'Unknown User Agent')
}), }),
{ {
headers: { headers: {