Skip to content

Commit eebd35e

Browse files
committed
fixes
1 parent 8eb6cb5 commit eebd35e

File tree

15 files changed

+1306
-202
lines changed

15 files changed

+1306
-202
lines changed

js/botasaurus-desktop-api/src/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ export interface Task {
3434
scraper_name: string;
3535
scraper_type: string;
3636
is_all_task: boolean;
37-
is_sync: boolean;
37+
priority: number;
3838
is_large: boolean;
3939
parent_task_id: number | null;
4040
duration: number | null;

js/botasaurus-desktop-api/src/utils.ts

Lines changed: 23 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,35 @@
11
import fs from 'fs';
22
import path from 'path';
33

4+
/**
5+
* Removes everything after (and including) the first single slash (/) in a string,
6+
* but skips over '//' (double slashes), which are used in protocols like 'http://'.
7+
* This is primarily used to extract the base URL (protocol + host) from a full URL.
8+
*
9+
* Example:
10+
* removeAfterFirstSlash("https://example.com/api/v1") // "https://example.com"
11+
* removeAfterFirstSlash("http://foo/bar/baz") // "http://foo"
12+
* removeAfterFirstSlash("localhost:8000/api/v1") // "localhost:8000"
13+
* removeAfterFirstSlash("https://example.com") // "https://example.com"
14+
*/
415
function removeAfterFirstSlash(inputString: string): string {
516
let i = 0;
617
const strLen = inputString.length;
7-
while (true) {
8-
if (i < strLen) {
9-
const char = inputString[i];
10-
if (char === '/') {
11-
if (i + 1 < inputString.length && inputString[i + 1] === '/') {
12-
i += 2;
13-
continue;
14-
} else {
15-
return inputString.substring(0, i);
16-
}
18+
while (i < strLen) {
19+
const char = inputString[i];
20+
if (char === '/') {
21+
// Check for double slash (e.g., 'http://')
22+
if (i + 1 < strLen && inputString[i + 1] === '/') {
23+
i += 2;
24+
continue;
25+
} else {
26+
// Single slash: trim here
27+
return inputString.substring(0, i);
1728
}
18-
i++;
19-
} else {
20-
break;
2129
}
30+
i++;
2231
}
32+
// No single slash found (or only part of protocol), return the whole input
2333
return inputString;
2434
}
2535

js/botasaurus-server-js/package-lock.json

Lines changed: 16 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

js/botasaurus-server-js/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -208,6 +208,7 @@
208208
},
209209
"dependencies": {
210210
"@seald-io/nedb": "latest",
211+
"async-mutex": "^0.5.0",
211212
"botasaurus": "latest",
212213
"botasaurus-controls": "latest",
213214
"change-case": "^5.4.4",

0 commit comments

Comments
 (0)