Skip to main content
Glama

LLM Researcher

by Code-Hex
search.test.ts1.84 kB
import { describe, it, expect } from "vitest"; import { DuckDuckGoSearcher } from "@/search.js"; import { readFileSync } from "fs"; import { join } from "path"; describe("DuckDuckGoSearcher pagination parsing", () => { it("should correctly parse pagination info from page 1 HTML", () => { const searcher = new DuckDuckGoSearcher(); // Read the actual HTML we fetched const html = readFileSync(join(__dirname, "fixtures", "ddg_page1.html"), "utf8"); const paginationInfo = searcher.parsePaginationInfo(html); console.log("Page 1 pagination info:", paginationInfo); // Page 1 should have Next but no Previous expect(paginationInfo.hasNext).toBe(true); expect(paginationInfo.hasPrevious).toBe(false); // Check extracted Next page parameters expect(paginationInfo.nextPageParams).toBeDefined(); expect(paginationInfo.nextPageParams?.s).toBe("10"); expect(paginationInfo.nextPageParams?.q).toBe("codehex"); }); it("should correctly extract next page URL parameters", () => { const searcher = new DuckDuckGoSearcher(); const html = readFileSync(join(__dirname, "fixtures", "ddg_page1.html"), "utf8"); const paginationInfo = searcher.parsePaginationInfo(html); // Build next page URL using extracted parameters if (paginationInfo.nextPageParams) { const nextUrl = new URLSearchParams(paginationInfo.nextPageParams); console.log("Next page URL params:", nextUrl.toString()); // Test that we can construct a proper next page URL const query = paginationInfo.nextPageParams.q; const offset = paginationInfo.nextPageParams.s; const expectedNextUrl = `https://duckduckgo.com/html/?q=${encodeURIComponent( query ?? "" )}&s=${offset}&kl=us-en`; console.log("Expected next URL:", expectedNextUrl); } }); });

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/Code-Hex/light-research-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server