File tree Expand file tree Collapse file tree 5 files changed +36
-12
lines changed Expand file tree Collapse file tree 5 files changed +36
-12
lines changed Original file line number Diff line number Diff line change 2
2
{
3
3
"time" : 1735911273239 ,
4
4
"options" : {
5
- "url" : " http://default- fire-engine-api-service:8080 /scrape" ,
5
+ "url" : " < fire-engine> /scrape" ,
6
6
"method" : " POST" ,
7
7
"body" : {
8
8
"url" : " http://firecrawl.dev" ,
27
27
{
28
28
"time" : 1735911273354 ,
29
29
"options" : {
30
- "url" : " http://default- fire-engine-api-service:8080 /scrape/ede37286-90db-4f60-8efb-76217dfcfa35!chrome-cdp" ,
30
+ "url" : " < fire-engine> /scrape/ede37286-90db-4f60-8efb-76217dfcfa35!chrome-cdp" ,
31
31
"method" : " GET" ,
32
32
"headers" : {},
33
33
"ignoreResponse" : false ,
43
43
{
44
44
"time" : 1735911273720 ,
45
45
"options" : {
46
- "url" : " http://default- fire-engine-api-service:8080 /scrape/ede37286-90db-4f60-8efb-76217dfcfa35!chrome-cdp" ,
46
+ "url" : " < fire-engine> /scrape/ede37286-90db-4f60-8efb-76217dfcfa35!chrome-cdp" ,
47
47
"method" : " GET" ,
48
48
"headers" : {},
49
49
"ignoreResponse" : false ,
59
59
{
60
60
"time" : 1735911274092 ,
61
61
"options" : {
62
- "url" : " http://default- fire-engine-api-service:8080 /scrape/ede37286-90db-4f60-8efb-76217dfcfa35!chrome-cdp" ,
62
+ "url" : " < fire-engine> /scrape/ede37286-90db-4f60-8efb-76217dfcfa35!chrome-cdp" ,
63
63
"method" : " GET" ,
64
64
"headers" : {},
65
65
"ignoreResponse" : false ,
75
75
{
76
76
"time" : 1735911274467 ,
77
77
"options" : {
78
- "url" : " http://default- fire-engine-api-service:8080 /scrape/ede37286-90db-4f60-8efb-76217dfcfa35!chrome-cdp" ,
78
+ "url" : " < fire-engine> /scrape/ede37286-90db-4f60-8efb-76217dfcfa35!chrome-cdp" ,
79
79
"method" : " GET" ,
80
80
"headers" : {},
81
81
"ignoreResponse" : false ,
91
91
{
92
92
"time" : 1735911274947 ,
93
93
"options" : {
94
- "url" : " http://default- fire-engine-api-service:8080 /scrape/ede37286-90db-4f60-8efb-76217dfcfa35!chrome-cdp" ,
94
+ "url" : " < fire-engine> /scrape/ede37286-90db-4f60-8efb-76217dfcfa35!chrome-cdp" ,
95
95
"method" : " GET" ,
96
96
"headers" : {},
97
97
"ignoreResponse" : false ,
Original file line number Diff line number Diff line change @@ -35,4 +35,24 @@ describe("Scrape tests", () => {
35
35
"this is fake data coming from the mocking system!" ,
36
36
) ;
37
37
} ) ;
38
+
39
+ describe ( "Location API" , ( ) => {
40
+ it . concurrent ( "works without specifying an explicit location" , async ( ) => {
41
+ const response = await scrape ( {
42
+ url : "https://iplocation.com" ,
43
+ } ) ;
44
+
45
+ expectScrapeToSucceed ( response ) ;
46
+ } ) ;
47
+
48
+ it . concurrent ( "works with country US" , async ( ) => {
49
+ const response = await scrape ( {
50
+ url : "https://iplocation.com" ,
51
+ location : { country : "US" } ,
52
+ } ) ;
53
+
54
+ expectScrapeToSucceed ( response ) ;
55
+ expect ( response . body . data . markdown ) . toContain ( "| Country | United States |" ) ;
56
+ } ) ;
57
+ } )
38
58
} ) ;
Original file line number Diff line number Diff line change @@ -154,13 +154,13 @@ export const scrapeOptions = z
154
154
. string ( )
155
155
. optional ( )
156
156
. refine (
157
- ( val ) => ! val || Object . keys ( countries ) . includes ( val . toUpperCase ( ) ) ,
157
+ ( val ) => ! val || Object . keys ( countries ) . includes ( val . toUpperCase ( ) ) || val === "US-generic" ,
158
158
{
159
159
message :
160
160
"Invalid country code. Please use a valid ISO 3166-1 alpha-2 country code." ,
161
161
} ,
162
162
)
163
- . transform ( ( val ) => ( val ? val . toUpperCase ( ) : "US" ) ) ,
163
+ . transform ( ( val ) => ( val ? val . toUpperCase ( ) : "US-generic " ) ) ,
164
164
languages : z . string ( ) . array ( ) . optional ( ) ,
165
165
} )
166
166
. optional ( ) ,
@@ -178,7 +178,7 @@ export const scrapeOptions = z
178
178
"Invalid country code. Please use a valid ISO 3166-1 alpha-2 country code." ,
179
179
} ,
180
180
)
181
- . transform ( ( val ) => ( val ? val . toUpperCase ( ) : "US" ) ) ,
181
+ . transform ( ( val ) => ( val ? val . toUpperCase ( ) : "US-generic " ) ) ,
182
182
languages : z . string ( ) . array ( ) . optional ( ) ,
183
183
} )
184
184
. optional ( ) ,
Original file line number Diff line number Diff line change @@ -126,10 +126,14 @@ export async function robustFetch<
126
126
const makeRequestTypeId = (
127
127
request : ( typeof mock ) [ "requests" ] [ number ] [ "options" ] ,
128
128
) => {
129
- let out = request . url + ";" + request . method ;
129
+ let trueUrl = ( process . env . FIRE_ENGINE_BETA_URL && request . url . startsWith ( process . env . FIRE_ENGINE_BETA_URL ) )
130
+ ? request . url . replace ( process . env . FIRE_ENGINE_BETA_URL , "<fire-engine>" )
131
+ : request . url ;
132
+
133
+ let out = trueUrl + ";" + request . method ;
130
134
if (
131
135
process . env . FIRE_ENGINE_BETA_URL &&
132
- url . startsWith ( process . env . FIRE_ENGINE_BETA_URL ) &&
136
+ ( trueUrl . startsWith ( "<fire-engine>" ) ) &&
133
137
request . method === "POST"
134
138
) {
135
139
out += "f-e;" + request . body ?. engine + ";" + request . body ?. url ;
Original file line number Diff line number Diff line change @@ -3,7 +3,7 @@ import * as path from "path";
3
3
import { logger as _logger } from "../../../lib/logger" ;
4
4
import { Logger } from "winston" ;
5
5
const saveMocksDirPath = path . join ( __dirname , "../mocks/" ) . replace ( "dist/" , "" ) ;
6
- const loadMocksDirPath = path . join ( __dirname , "../../../__tests__/snips/mocks" ) ;
6
+ const loadMocksDirPath = path . join ( __dirname , "../../../__tests__/snips/mocks" ) . replace ( "dist/" , "" ) ;
7
7
8
8
export async function saveMock ( options : unknown , result : unknown ) {
9
9
if ( process . env . FIRECRAWL_SAVE_MOCKS !== "true" ) return ;
You can’t perform that action at this time.
0 commit comments