diff --git a/extensions/duckduckgo/src/ddg-client.ts b/extensions/duckduckgo/src/ddg-client.ts
index 497f13e8f642..f5d484c66511 100644
--- a/extensions/duckduckgo/src/ddg-client.ts
+++ b/extensions/duckduckgo/src/ddg-client.ts
@@ -53,7 +53,9 @@ function decodeHtmlEntities(text: string): string {
}
function stripHtml(html: string): string {
- return html
+ // DuckDuckGo match highlights can occur inside words, so remove them without adding whitespace.
+ const withoutMatchHighlights = html.replace(/<\/?b\b[^>]*>/gi, "");
+ return withoutMatchHighlights
.replace(/<[^>]+>/g, " ")
.replace(/\s+/g, " ")
.trim();
diff --git a/extensions/duckduckgo/src/ddg-search-provider.test.ts b/extensions/duckduckgo/src/ddg-search-provider.test.ts
index 608caefe54f8..53ab34d503d0 100644
--- a/extensions/duckduckgo/src/ddg-search-provider.test.ts
+++ b/extensions/duckduckgo/src/ddg-search-provider.test.ts
@@ -254,6 +254,21 @@ describe("duckduckgo web search provider", () => {
]);
});
+ it("keeps inline result markup from splitting words", () => {
+ const html = `
+ Café guide
+ Find the best café near you.
+ `;
+
+ expect(ddgClientTesting.parseDuckDuckGoHtml(html)).toEqual([
+ {
+ title: "Café guide",
+ url: "https://example.com/cafe",
+ snippet: "Find the best café near you.",
+ },
+ ]);
+ });
+
it("detects bot challenge pages without flagging ordinary result snippets", () => {
const challengeHtml = `