Skip to content

7.4 billion tokens per month. 34 free LLM providers. 635 free model endpoints. All behind one /v1 endpoint, plus any custom OpenAI-compatible endpoint. Smart routing, automatic failover, encrypted keys. Personal experimentation only.

TypeScript

fix(search): stop Brave decorating every hit with <strong> tags (#1687)

tashdroid602e58ed3380
diff --git a/server/src/__tests__/services/search.test.ts b/server/src/__tests__/services/search.test.ts
index 4a2fc0db..844ee177 100644
--- a/server/src/__tests__/services/search.test.ts
+++ b/server/src/__tests__/services/search.test.ts
@@ -170,6 +170,9 @@ describe('search service', () => {
expect(`${url.origin}${url.pathname}`).toBe('https://api.search.brave.com/res/v1/web/search');
expect(url.searchParams.get('q')).toBe('cats & dogs');
expect(url.searchParams.get('count')).toBe('3');
+ // Brave decorates matched terms with <strong> unless asked not to;
+ // without this the hits carry raw markup every other engine never emits.
+ expect(url.searchParams.get('text_decorations')).toBe('false');
expect(new Headers(calls(fn)[0][1].headers).get('x-subscription-token')).toBe('brave-test-key');
expect(out).toMatchObject({ provider: 'brave', engine: 'brave-search', results: [{ title: 'A & B', url: 'https://a', content: 'alpha', score: 1 }] });
diff --git a/server/src/services/search.ts b/server/src/services/search.ts
index 237180e9..569435c3 100644
--- a/server/src/services/search.ts
+++ b/server/src/services/search.ts
@@ -337,6 +337,10 @@ const ADAPTERS: Record<string, Adapter> = {
const url = new URL(`${BRAVE_BASE_URL}/${news ? 'news' : 'web'}/search`);
url.searchParams.set('q', query);
url.searchParams.set('count', String(n));
+ // Brave decorates matched terms with <strong> tags by default
+ // (text_decorations=true), so titles and snippets would reach the caller
+ // wrapped in markup every other engine never emits. Ask for plain text.
+ url.searchParams.set('text_decorations', 'false');
let parsed: { web?: { results?: unknown }; results?: unknown } | null;
try {
parsed = await upstream(url.toString(), 'brave', {