Skip to content

Commit d02f7bb

Browse files
committed
fix: remove grab-url import from docx-to-content.ts
1 parent 0db6c23 commit d02f7bb

3 files changed

Lines changed: 30 additions & 1 deletion

File tree

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
4a0953a5-7172-4699-889a-56bf53a2388d
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
[]

packages/extract-webpage/src/url-to-content/docx-to-content.ts

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,34 @@
44
* @description Research library module.
55
*/
66
import JSZip from "jszip";
7-
import grab from "grab-url";
7+
8+
/**
9+
* Fetch wrapper for grabbing binary content
10+
*/
11+
async function grab(url: string, options: { responseType?: string; timeout?: number } = {}) {
12+
const timeout = options.timeout ? options.timeout * 1000 : 10000;
13+
const controller = new AbortController();
14+
const timeoutId = setTimeout(() => controller.abort(), timeout);
15+
16+
try {
17+
const response = await fetch(url, {
18+
signal: controller.signal,
19+
});
20+
clearTimeout(timeoutId);
21+
22+
if (!response.ok) {
23+
throw new Error(`HTTP ${response.status}`);
24+
}
25+
26+
if (options.responseType === "arraybuffer") {
27+
return await response.arrayBuffer();
28+
}
29+
return await response.text();
30+
} catch (error) {
31+
clearTimeout(timeoutId);
32+
throw error;
33+
}
34+
}
835

936
/**
1037
* Configuration options for DOCX parsing

0 commit comments

Comments
 (0)