MCPcopy Create free account
hub / github.com/QodeXcli/QodeX / unwrapDdgRedirect

Function unwrapDdgRedirect

src/tools/web/parse.ts:111–121  ·  view source on GitHub ↗
(url: string)

Source from the content-addressed store, hash-verified

109
110/** Unwrap DuckDuckGo's `//duckduckgo.com/l/?uddg=<encoded>` tracking redirect. */
111export function unwrapDdgRedirect(url: string): string {
112 const abs = url.startsWith('//') ? 'https:' + url : url;
113 try {
114 const u = new URL(abs);
115 if (u.hostname === 'duckduckgo.com' && u.pathname === '/l/') {
116 const real = u.searchParams.get('uddg');
117 if (real) return decodeURIComponent(real);
118 }
119 } catch { /* fall through */ }
120 return abs;
121}
122
123export function stripTags(html: string): string {
124 return html

Callers 4

web-search.test.tsFile · 0.85
parseDuckDuckGoHtmlFunction · 0.85
parseDuckDuckGoLiteHtmlFunction · 0.85

Calls 1

getMethod · 0.45

Tested by

no test coverage detected