fix(api): remove double URL-encoding in telegram-feed relay (#2108)

encodeURIComponent() is applied before URLSearchParams.set(), which
already percent-encodes its value. This double-encodes special chars
(e.g., space becomes %2520 instead of %20), causing relay queries
with special characters in topic/channel to return wrong or empty
results.

Co-authored-by: warren618 <warren618@users.noreply.github.com>
Co-authored-by: Elie Habib <elie.habib@gmail.com>
This commit is contained in:
Haozhe Wu
2026-03-23 13:14:40 +08:00
committed by GitHub
parent 16936e7cec
commit d8406190c7

View File

@@ -29,8 +29,8 @@ export default async function handler(req) {
const channel = (url.searchParams.get('channel') || '').trim(); const channel = (url.searchParams.get('channel') || '').trim();
const params = new URLSearchParams(); const params = new URLSearchParams();
params.set('limit', String(limit)); params.set('limit', String(limit));
if (topic) params.set('topic', encodeURIComponent(topic)); if (topic) params.set('topic', topic);
if (channel) params.set('channel', encodeURIComponent(channel)); if (channel) params.set('channel', channel);
const relayUrl = `${relayBaseUrl}/telegram/feed?${params}`; const relayUrl = `${relayBaseUrl}/telegram/feed?${params}`;
const response = await fetchWithTimeout(relayUrl, { const response = await fetchWithTimeout(relayUrl, {