The modern link attribution platform. Loved by world-class engineering teams at Twilio, Zillow, Jobber, Vercel, Raycast, and more.
TypeScript clickhousemysqlnextjsopen-sourceplanetscaleprismatailwindcsstinybirdtypescriptupstashvercel
bump node version
Steven Tey0112e6c5703b
diff --git a/apps/web/app/api/cron/import/bitly/sanitize-json.ts b/apps/web/app/api/cron/import/bitly/sanitize-json.tsindex 66099bf68d..d00b14f69a 100644--- a/apps/web/app/api/cron/import/bitly/sanitize-json.ts+++ b/apps/web/app/api/cron/import/bitly/sanitize-json.ts@@ -1,33 +1,27 @@-export const sanitizeBitlyJson = (json: string): string => {- try {- // Apply the regex first to simplify the structure- const simplifiedJson = json.replace(- /"long_url":"([^"]+)".+?"archived"/g,- '"long_url":"$1","archived"',- );+export function sanitizeBitlyJson(body: string): string {+ // First, remove "title" field which can sometimes contain invalid values that break the JSON parsing+ body = body.replace(+ /"long_url":"([^"]+)".+?"archived"/g,+ '"long_url":"$1","archived"',+ );- // Then handle control characters- return simplifiedJson.replace(/[\u0000-\u001F\u007F-\u009F]/g, (char) => {- // Convert to proper JSON escape sequence if it's a common one- switch (char) {- case "\n":- return "\\n";- case "\r":- return "\\r";- case "\t":- return "\\t";- case "\b":- return "\\b";- case "\f":- return "\\f";- // Remove or replace other control characters- default:- return "";- }- });- } catch (error) {- console.error("Error in sanitizing JSON:", error);- // Return the original JSON if sanitization fails- return json;- }-};+ // Then handle control characters+ return body.replace(/[\u0000-\u001F\u007F-\u009F]/g, (char) => {+ // Convert to proper JSON escape sequence if it's a common one+ switch (char) {+ case "\n":+ return "\\n";+ case "\r":+ return "\\r";+ case "\t":+ return "\\t";+ case "\b":+ return "\\b";+ case "\f":+ return "\\f";+ // Remove or replace other control characters+ default:+ return "";+ }+ });+}