mirror of
https://github.com/upstash/context7.git
synced 2025-06-26 23:50:04 +00:00
refactor: remove folders parameter support from library documentation fetching
This commit is contained in:
parent
ce2a63a37a
commit
e50ee0dfd3
13
src/index.ts
13
src/index.ts
@ -135,20 +135,9 @@ server.tool(
|
||||
),
|
||||
},
|
||||
async ({ context7CompatibleLibraryID, tokens = DEFAULT_MINIMUM_TOKENS, topic = "" }) => {
|
||||
// Extract folders parameter if present in the ID
|
||||
let folders = "";
|
||||
let libraryId = context7CompatibleLibraryID;
|
||||
|
||||
if (context7CompatibleLibraryID.includes("?folders=")) {
|
||||
const [id, foldersParam] = context7CompatibleLibraryID.split("?folders=");
|
||||
libraryId = id;
|
||||
folders = foldersParam;
|
||||
}
|
||||
|
||||
const documentationText = await fetchLibraryDocumentation(libraryId, {
|
||||
const documentationText = await fetchLibraryDocumentation(context7CompatibleLibraryID, {
|
||||
tokens,
|
||||
topic,
|
||||
folders,
|
||||
});
|
||||
|
||||
if (!documentationText) {
|
||||
|
@ -35,7 +35,6 @@ export async function fetchLibraryDocumentation(
|
||||
options: {
|
||||
tokens?: number;
|
||||
topic?: string;
|
||||
folders?: string;
|
||||
} = {}
|
||||
): Promise<string | null> {
|
||||
try {
|
||||
@ -45,7 +44,6 @@ export async function fetchLibraryDocumentation(
|
||||
const url = new URL(`${CONTEXT7_API_BASE_URL}/v1/${libraryId}`);
|
||||
if (options.tokens) url.searchParams.set("tokens", options.tokens.toString());
|
||||
if (options.topic) url.searchParams.set("topic", options.topic);
|
||||
if (options.folders) url.searchParams.set("folders", options.folders);
|
||||
url.searchParams.set("type", DEFAULT_TYPE);
|
||||
const response = await fetch(url, {
|
||||
headers: {
|
||||
|
Loading…
x
Reference in New Issue
Block a user