Try to handle response body as a JSON first before handling it as a plain text

This commit is contained in:
aminosred25
2025-09-21 22:33:57 +02:00
committed by GitHub
parent 225362d351
commit bfbb2710b6

View File

@@ -146,10 +146,7 @@ Future<List<MapEntry<String, String>>> grabLinksCommon(
.map((e) => MapEntry(ensureAbsoluteUrl(e.key, reqUrl), e.value))
.toList();
if (allLinks.isEmpty || matchLinksOutsideATags) {
allLinks = getLinksInLines(rawBody);
}
if (allLinks.isEmpty) {
// Getting desperate
// Decode the body if the response is a JSON
try {
var jsonStrings = collectAllStringsFromJSONObject(jsonDecode(rawBody));
allLinks = getLinksInLines(jsonStrings.join('\n'));
@@ -163,7 +160,7 @@ Future<List<MapEntry<String, String>>> grabLinksCommon(
);
}
} catch (e) {
//
allLinks = getLinksInLines(rawBody);
}
}
List<MapEntry<String, String>> links = [];