Skip to content

Supercharge your AI agents with data from the web and beyond. Building the library for superintelligence. 🔥

Nick:

Nicolase200ec9e1217
diff --git a/apps/api/src/__tests__/e2e_v1_withAuth/index.test.ts b/apps/api/src/__tests__/e2e_v1_withAuth/index.test.ts
index b58e52abb..3bb26e983 100644
--- a/apps/api/src/__tests__/e2e_v1_withAuth/index.test.ts
+++ b/apps/api/src/__tests__/e2e_v1_withAuth/index.test.ts
@@ -513,6 +513,81 @@ describe("POST /v1/map", () => {
expect(links[0]).toContain("usemotion.com/pricing");
});
+ it.concurrent("should return a successful response with a valid API key and search and allowSubdomains", async () => {
+ const mapRequest = {
+ url: "https://firecrawl.dev",
+ search: "docs",
+ includeSubdomains: true
+ };
+
+ const response: ScrapeResponseRequestTest = await request(TEST_URL)
+ .post("/v1/map")
+ .set("Authorization", `Bearer ${process.env.TEST_API_KEY}`)
+ .set("Content-Type", "application/json")
+ .send(mapRequest);
+
+ expect(response.statusCode).toBe(200);
+ expect(response.body).toHaveProperty("success", true);
+ expect(response.body).toHaveProperty("links");
+ if (!("links" in response.body)) {
+ throw new Error("Expected response body to have 'links' property");
+ }
+ const links = response.body.links as unknown[];
+ expect(Array.isArray(links)).toBe(true);
+ expect(links.length).toBeGreaterThan(0);
+ expect(links[0]).toContain("docs.firecrawl.dev");
+ });
+
+ it.concurrent("should return a successful response with a valid API key and search and allowSubdomains and www", async () => {
+ const mapRequest = {
+ url: "https://www.firecrawl.dev",
+ search: "docs",
+ includeSubdomains: true
+ };
+
+ const response: ScrapeResponseRequestTest = await request(TEST_URL)
+ .post("/v1/map")
+ .set("Authorization", `Bearer ${process.env.TEST_API_KEY}`)
+ .set("Content-Type", "application/json")
+ .send(mapRequest);
+
+ expect(response.statusCode).toBe(200);
+ expect(response.body).toHaveProperty("success", true);
+ expect(response.body).toHaveProperty("links");
+ if (!("links" in response.body)) {
+ throw new Error("Expected response body to have 'links' property");
+ }
+ const links = response.body.links as unknown[];
+ expect(Array.isArray(links)).toBe(true);
+ expect(links.length).toBeGreaterThan(0);
+ expect(links[0]).toContain("docs.firecrawl.dev");
+ }, 10000)
+
+ it.concurrent("should return a successful response with a valid API key and search and not allowSubdomains and www", async () => {
+ const mapRequest = {
+ url: "https://www.firecrawl.dev",
+ search: "docs",
+ includeSubdomains: false
+ };
+
+ const response: ScrapeResponseRequestTest = await request(TEST_URL)
+ .post("/v1/map")
+ .set("Authorization", `Bearer ${process.env.TEST_API_KEY}`)
+ .set("Content-Type", "application/json")
+ .send(mapRequest);
+
+ expect(response.statusCode).toBe(200);
+ expect(response.body).toHaveProperty("success", true);
+ expect(response.body).toHaveProperty("links");
+ if (!("links" in response.body)) {
+ throw new Error("Expected response body to have 'links' property");
+ }
+ const links = response.body.links as unknown[];
+ expect(Array.isArray(links)).toBe(true);
+ expect(links.length).toBeGreaterThan(0);
+ expect(links[0]).not.toContain("docs.firecrawl.dev");
+ })
+
it.concurrent("should return an error for invalid URL", async () => {
const mapRequest = {
url: "invalid-url",
diff --git a/apps/api/src/controllers/v1/map.ts b/apps/api/src/controllers/v1/map.ts
index a50b76159..08d5ab611 100644
--- a/apps/api/src/controllers/v1/map.ts
+++ b/apps/api/src/controllers/v1/map.ts
@@ -48,8 +48,10 @@ export async function mapController(
});
}
+ let urlWithoutWww = req.body.url.replace("www.", "");
+
let mapUrl = req.body.search
- ? `"${req.body.search}" site:${req.body.url}`
+ ? `"${req.body.search}" site:${urlWithoutWww}`
: `site:${req.body.url}`;
// www. seems to exclude subdomains in some cases
const mapResults = await fireEngineMap(mapUrl, {
diff --git a/apps/api/src/controllers/v1/types.ts b/apps/api/src/controllers/v1/types.ts
index 333f582e2..3fe358914 100644
--- a/apps/api/src/controllers/v1/types.ts
+++ b/apps/api/src/controllers/v1/types.ts
@@ -116,7 +116,7 @@ export type CrawlRequest = z.infer<typeof crawlRequestSchema>;
export const mapRequestSchema = crawlerOptions.extend({
url: z.string().url(),
origin: z.string().optional().default("api"),
- includeSubdomains: z.boolean().default(false),
+ includeSubdomains: z.boolean().default(true),
search: z.string().optional(),
ignoreSitemap: z.boolean().default(false),
});