mirror of
https://github.com/upstash/context7.git
synced 2025-07-03 07:04:25 +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 = "" }) => {
|
async ({ context7CompatibleLibraryID, tokens = DEFAULT_MINIMUM_TOKENS, topic = "" }) => {
|
||||||
// Extract folders parameter if present in the ID
|
const documentationText = await fetchLibraryDocumentation(context7CompatibleLibraryID, {
|
||||||
let folders = "";
|
|
||||||
let libraryId = context7CompatibleLibraryID;
|
|
||||||
|
|
||||||
if (context7CompatibleLibraryID.includes("?folders=")) {
|
|
||||||
const [id, foldersParam] = context7CompatibleLibraryID.split("?folders=");
|
|
||||||
libraryId = id;
|
|
||||||
folders = foldersParam;
|
|
||||||
}
|
|
||||||
|
|
||||||
const documentationText = await fetchLibraryDocumentation(libraryId, {
|
|
||||||
tokens,
|
tokens,
|
||||||
topic,
|
topic,
|
||||||
folders,
|
|
||||||
});
|
});
|
||||||
|
|
||||||
if (!documentationText) {
|
if (!documentationText) {
|
||||||
|
@ -35,7 +35,6 @@ export async function fetchLibraryDocumentation(
|
|||||||
options: {
|
options: {
|
||||||
tokens?: number;
|
tokens?: number;
|
||||||
topic?: string;
|
topic?: string;
|
||||||
folders?: string;
|
|
||||||
} = {}
|
} = {}
|
||||||
): Promise<string | null> {
|
): Promise<string | null> {
|
||||||
try {
|
try {
|
||||||
@ -45,7 +44,6 @@ export async function fetchLibraryDocumentation(
|
|||||||
const url = new URL(`${CONTEXT7_API_BASE_URL}/v1/${libraryId}`);
|
const url = new URL(`${CONTEXT7_API_BASE_URL}/v1/${libraryId}`);
|
||||||
if (options.tokens) url.searchParams.set("tokens", options.tokens.toString());
|
if (options.tokens) url.searchParams.set("tokens", options.tokens.toString());
|
||||||
if (options.topic) url.searchParams.set("topic", options.topic);
|
if (options.topic) url.searchParams.set("topic", options.topic);
|
||||||
if (options.folders) url.searchParams.set("folders", options.folders);
|
|
||||||
url.searchParams.set("type", DEFAULT_TYPE);
|
url.searchParams.set("type", DEFAULT_TYPE);
|
||||||
const response = await fetch(url, {
|
const response = await fetch(url, {
|
||||||
headers: {
|
headers: {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user