From a4f6ce42c67b83b9dd6e785125868fda7ff47e35 Mon Sep 17 00:00:00 2001 From: Jesse Wierzbinski Date: Thu, 11 Apr 2024 04:01:12 -1000 Subject: [PATCH] Don't accidentally send mixed content to the client --- utils/timelines.ts | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/utils/timelines.ts b/utils/timelines.ts index 66cc2f82..3a0ce839 100644 --- a/utils/timelines.ts +++ b/utils/timelines.ts @@ -5,6 +5,7 @@ import type { Notification, } from "~database/entities/Notification"; import type { db } from "~drizzle/db"; +import { config } from "config-manager"; export async function fetchTimeline( model: @@ -24,6 +25,10 @@ export async function fetchTimeline( // Constuct HTTP Link header (next and prev) only if there are more statuses const linkHeader = []; + const urlWithoutQuery = new URL( + new URL(req.url).pathname, + config.http.base_url, + ).toString(); if (objects.length > 0) { // Check if there are statuses before the first one @@ -36,7 +41,6 @@ export async function fetchTimeline( }); if (objectsBefore.length > 0) { - const urlWithoutQuery = req.url.split("?")[0]; // Add prev link linkHeader.push( `<${urlWithoutQuery}?limit=${args?.limit ?? 20}&min_id=${ @@ -56,7 +60,6 @@ export async function fetchTimeline( }); if (objectsAfter.length > 0) { - const urlWithoutQuery = req.url.split("?")[0]; // Add next link linkHeader.push( `<${urlWithoutQuery}?limit=${args?.limit ?? 20}&max_id=${