openclaw-smart-fetch 0.2.30 → 0.2.31
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +30 -16
- package/dist/index.js.map +1 -1
- package/openclaw.plugin.json +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -10203,25 +10203,10 @@ function createDefuddleFetch(dependencies = runtimeDependencies) {
|
|
|
10203
10203
|
});
|
|
10204
10204
|
const fallbackDocument = parseLinkedomHTML(rawBody, finalUrl);
|
|
10205
10205
|
const extractionDocument = parseLinkedomHTML(rawBody, finalUrl);
|
|
10206
|
-
if (isTwitterJsDisabledPage(fallbackDocument, opts.url)) {
|
|
10207
|
-
return {
|
|
10208
|
-
error: `Server returned HTTP 404 Not Found for ${opts.url}.`,
|
|
10209
|
-
code: "http_error",
|
|
10210
|
-
phase: "loading",
|
|
10211
|
-
retryable: false,
|
|
10212
|
-
timeoutMs,
|
|
10213
|
-
url: opts.url,
|
|
10214
|
-
finalUrl,
|
|
10215
|
-
statusCode: 404,
|
|
10216
|
-
statusText: "Not Found",
|
|
10217
|
-
mimeType: normalizeContentType(contentType) || void 0,
|
|
10218
|
-
contentLength: errorContext.contentLength
|
|
10219
|
-
};
|
|
10220
|
-
}
|
|
10221
10206
|
let extracted;
|
|
10207
|
+
const suppressedErrors = [];
|
|
10222
10208
|
try {
|
|
10223
10209
|
const origConsoleError = console.error;
|
|
10224
|
-
const suppressedErrors = [];
|
|
10225
10210
|
console.error = (...args) => {
|
|
10226
10211
|
suppressedErrors.push(args);
|
|
10227
10212
|
};
|
|
@@ -10244,6 +10229,35 @@ function createDefuddleFetch(dependencies = runtimeDependencies) {
|
|
|
10244
10229
|
wordCount: 0
|
|
10245
10230
|
};
|
|
10246
10231
|
}
|
|
10232
|
+
const isXUrl = /^https?:\/\/(www\.)?(x\.com|twitter\.com)\//i.test(
|
|
10233
|
+
opts.url
|
|
10234
|
+
);
|
|
10235
|
+
if (isXUrl) {
|
|
10236
|
+
const hasOembed404 = suppressedErrors.some(
|
|
10237
|
+
(args) => args.some(
|
|
10238
|
+
(arg) => typeof arg === "string" && arg.includes("oEmbed request failed: 404")
|
|
10239
|
+
)
|
|
10240
|
+
);
|
|
10241
|
+
const hasJsDisabledShell = isTwitterJsDisabledPage(
|
|
10242
|
+
fallbackDocument,
|
|
10243
|
+
opts.url
|
|
10244
|
+
);
|
|
10245
|
+
if (hasOembed404 || hasJsDisabledShell) {
|
|
10246
|
+
return {
|
|
10247
|
+
error: `Server returned HTTP 404 Not Found for ${opts.url}.`,
|
|
10248
|
+
code: "http_error",
|
|
10249
|
+
phase: "loading",
|
|
10250
|
+
retryable: false,
|
|
10251
|
+
timeoutMs,
|
|
10252
|
+
url: opts.url,
|
|
10253
|
+
finalUrl,
|
|
10254
|
+
statusCode: 404,
|
|
10255
|
+
statusText: "Not Found",
|
|
10256
|
+
mimeType: normalizeContentType(contentType) || void 0,
|
|
10257
|
+
contentLength: errorContext.contentLength
|
|
10258
|
+
};
|
|
10259
|
+
}
|
|
10260
|
+
}
|
|
10247
10261
|
let extractedContent = extracted.content;
|
|
10248
10262
|
let wordCount = extracted.wordCount;
|
|
10249
10263
|
if (!extractedContent || wordCount === 0) {
|