Don't accidentally send mixed content to the client

This commit is contained in:
Jesse Wierzbinski 2024-04-11 04:01:12 -10:00
parent 6b3c604c33
commit a4f6ce42c6
No known key found for this signature in database

View file

@ -5,6 +5,7 @@ import type {
Notification, Notification,
} from "~database/entities/Notification"; } from "~database/entities/Notification";
import type { db } from "~drizzle/db"; import type { db } from "~drizzle/db";
import { config } from "config-manager";
export async function fetchTimeline<T extends User | Status | Notification>( export async function fetchTimeline<T extends User | Status | Notification>(
model: model:
@ -24,6 +25,10 @@ export async function fetchTimeline<T extends User | Status | Notification>(
// Constuct HTTP Link header (next and prev) only if there are more statuses // Constuct HTTP Link header (next and prev) only if there are more statuses
const linkHeader = []; const linkHeader = [];
const urlWithoutQuery = new URL(
new URL(req.url).pathname,
config.http.base_url,
).toString();
if (objects.length > 0) { if (objects.length > 0) {
// Check if there are statuses before the first one // Check if there are statuses before the first one
@ -36,7 +41,6 @@ export async function fetchTimeline<T extends User | Status | Notification>(
}); });
if (objectsBefore.length > 0) { if (objectsBefore.length > 0) {
const urlWithoutQuery = req.url.split("?")[0];
// Add prev link // Add prev link
linkHeader.push( linkHeader.push(
`<${urlWithoutQuery}?limit=${args?.limit ?? 20}&min_id=${ `<${urlWithoutQuery}?limit=${args?.limit ?? 20}&min_id=${
@ -56,7 +60,6 @@ export async function fetchTimeline<T extends User | Status | Notification>(
}); });
if (objectsAfter.length > 0) { if (objectsAfter.length > 0) {
const urlWithoutQuery = req.url.split("?")[0];
// Add next link // Add next link
linkHeader.push( linkHeader.push(
`<${urlWithoutQuery}?limit=${args?.limit ?? 20}&max_id=${ `<${urlWithoutQuery}?limit=${args?.limit ?? 20}&max_id=${