mirror of
https://git.mirrors.martin98.com/https://github.com/mendableai/firecrawl
synced 2025-08-18 01:35:57 +08:00
Fix map endpoint including non-existent URLs in results
Co-Authored-By: Nicolas Camara <nick@sideguide.dev>
This commit is contained in:
parent
ab6fb48e6e
commit
257556f424
@ -31,4 +31,23 @@ describe("Map tests", () => {
|
|||||||
expect(response.body.success).toBe(true);
|
expect(response.body.success).toBe(true);
|
||||||
expect(response.body.links.some(x => x.match(/^https:\/\/www\.hfea\.gov\.uk\/choose-a-clinic\/clinic-search\/results\/?\?options=\d+$/))).toBe(true);
|
expect(response.body.links.some(x => x.match(/^https:\/\/www\.hfea\.gov\.uk\/choose-a-clinic\/clinic-search\/results\/?\?options=\d+$/))).toBe(true);
|
||||||
}, 60000);
|
}, 60000);
|
||||||
|
|
||||||
|
it.concurrent("does not include non-existent child URLs in parent results", async () => {
|
||||||
|
const nonExistentPath = "/non-existent-path-" + Date.now(); // Use timestamp to ensure uniqueness
|
||||||
|
const childUrl = "https://firecrawl.dev" + nonExistentPath;
|
||||||
|
|
||||||
|
await map({
|
||||||
|
url: childUrl,
|
||||||
|
useMock: "map-non-existent-child",
|
||||||
|
});
|
||||||
|
|
||||||
|
const parentResponse = await map({
|
||||||
|
url: "https://firecrawl.dev",
|
||||||
|
useMock: "map-parent-after-child",
|
||||||
|
});
|
||||||
|
|
||||||
|
expect(parentResponse.statusCode).toBe(200);
|
||||||
|
expect(parentResponse.body.success).toBe(true);
|
||||||
|
expect(parentResponse.body.links.some(link => link.includes(nonExistentPath))).toBe(false);
|
||||||
|
}, 30000);
|
||||||
});
|
});
|
||||||
|
@ -161,8 +161,10 @@ export async function getMapResults({
|
|||||||
);
|
);
|
||||||
allResults = await Promise.all(pagePromises);
|
allResults = await Promise.all(pagePromises);
|
||||||
|
|
||||||
|
if (allResults.flat().filter(result => result !== null && result !== undefined).length > 0) {
|
||||||
await redis.set(cacheKey, JSON.stringify(allResults), "EX", 48 * 60 * 60); // Cache for 48 hours
|
await redis.set(cacheKey, JSON.stringify(allResults), "EX", 48 * 60 * 60); // Cache for 48 hours
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Parallelize sitemap index query with search results
|
// Parallelize sitemap index query with search results
|
||||||
const [sitemapIndexResult, ...searchResults] = await Promise.all([
|
const [sitemapIndexResult, ...searchResults] = await Promise.all([
|
||||||
|
Loading…
x
Reference in New Issue
Block a user