From 4b7e3f7ee5426c662723e3674ff943f344bed13e Mon Sep 17 00:00:00 2001 From: Cory Dransfeldt Date: Sun, 24 Mar 2024 20:19:34 -0700 Subject: [PATCH] chore: eventing + refactoring --- api/event.js | 11 ++++++++--- package.json | 2 +- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/api/event.js b/api/event.js index d770b6c2..4e2c63c5 100644 --- a/api/event.js +++ b/api/event.js @@ -8,11 +8,16 @@ export default async (request, context) => { const num = params.get('num') || 'unknown' const lang = decodeURIComponent(params.get('lang')) const nav = decodeURIComponent(params.get('nav')) + const notLang = !lang || lang === 'null' || lang === 'undefined' + const notNav = !nav || nav === 'null' || nav === 'undefined' const ig = params.get('ig') const setUrl = (id, event) => `https://cdn.usefathom.com/?h=${encodeURIComponent(page)}&sid=CWSVCDJC&cid=${id}&name=${encodeURIComponent(event)}` - const headers = {} - if (lang) headers['Accept-Language'] = lang - if (nav) headers['User-Agent'] = nav + const acceptLanguage = notLang ? request['headers'].get('accept-language') : lang + const userAgent = notNav ? request['headers'].get('user-agent') : nav + const headers = { + 'Accept-Language': acceptLanguage, + 'User-Agent': userAgent + } let url if (ig) return diff --git a/package.json b/package.json index 2360191c..dbbe8ef2 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "coryd.dev", - "version": "8.7.2", + "version": "8.7.3", "description": "The source for my personal site. Built using 11ty.", "type": "module", "scripts": {