diff --git a/Webserver/src/routes/api/reddit/+server.ts b/Webserver/src/routes/api/reddit/+server.ts index 6e58e77..b3729e7 100644 --- a/Webserver/src/routes/api/reddit/+server.ts +++ b/Webserver/src/routes/api/reddit/+server.ts @@ -17,6 +17,12 @@ export const GET: RequestHandler = async ({ url }) => { // Read data as string const text = await response.text(); + // Get all sources of posts + const regex = /]+role="presentation"[^>]+src="(.*?)"[^>]*>/g; + let results = [], match; + while ((match = regex.exec(text)) !== null) + results.push(match[1]); + // Return source data - return json({ success: true, results: text.split('\n') } as APIResponse); + return json({ success: true, results } as APIResponse); };