summaryrefslogtreecommitdiff
path: root/cgithub/src/scraper.ts
diff options
context:
space:
mode:
Diffstat (limited to 'cgithub/src/scraper.ts')
-rw-r--r--cgithub/src/scraper.ts7
1 files changed, 5 insertions, 2 deletions
diff --git a/cgithub/src/scraper.ts b/cgithub/src/scraper.ts
index 4ffdc43..4feda73 100644
--- a/cgithub/src/scraper.ts
+++ b/cgithub/src/scraper.ts
@@ -63,7 +63,7 @@ export interface GitHubRepo extends GitHubTree {
export interface GitHubBlob extends GitHubCommon {
language: string | null;
- size: number;
+ size: number | null;
content: string;
rawContent: string;
}
@@ -210,10 +210,13 @@ export async function getGitHubBlob(
const highlightedLines = blob.highlightedLines || [];
const content = highlightedLines.map((line) => line.text || "").join("\n");
+ // Calculate size from raw content if not provided
+ const size = blob.size ?? (rawContent.length > 0 ? Buffer.byteLength(rawContent, "utf8") : null);
+
return extractGitHub(payload, {
content: content || rawContent,
rawContent,
language: blob.language || null,
- size: blob.size,
+ size,
});
}