aboutsummaryrefslogtreecommitdiff
path: root/src/scraper.test.ts
diff options
context:
space:
mode:
authorJoe Mou <dev@mou.fo>2026-08-12 01:38:24 -0400
committerJoe Mou <dev@mou.fo>2026-08-12 01:42:59 -0400
commitca23e43e0e95014ddd5f8d5e02e1118f5e2978f5 (patch)
tree49a269b88f7f0d11e8102a60468f53252f033c4e /src/scraper.test.ts
parentf491b436e4506a9a56a6a6c4313f4d41a0f3b890 (diff)
Handle blobs GitHub cannot preview
Binary files with no preview (a .ttf, say) have no rawLines, no colorizedLines and no richText, so the blob view's final branch threw on a null textLines and the page 500ed. Offer the raw file instead. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Diffstat (limited to 'src/scraper.test.ts')
-rw-r--r--src/scraper.test.ts18
1 files changed, 18 insertions, 0 deletions
diff --git a/src/scraper.test.ts b/src/scraper.test.ts
index 24fdfc0..836235e 100644
--- a/src/scraper.test.ts
+++ b/src/scraper.test.ts
@@ -332,6 +332,24 @@ describe("GitHub scraper", () => {
assert.strictEqual(data.htmlLines, null);
assert.strictEqual(data.htmlContent, null);
});
+
+ // A binary file GitHub has no preview for: no content of any kind, and the
+ // path exercises escaping of a space.
+ it("should support an unpreviewable binary file", async () => {
+ const data = await getGitHubBlob("justrajdeep", "fonts", "master", "Times New Roman.ttf");
+
+ assert.strictEqual(data.repo.owner, "justrajdeep");
+ assert.strictEqual(data.repo.name, "fonts");
+ assert.strictEqual(data.branch, "master");
+ assert.strictEqual(data.path, "Times New Roman.ttf");
+
+ assert.strictEqual(data.size, "815 KB");
+ assert.strictEqual(data.language, null);
+ assert.strictEqual(data.image, false);
+ assert.strictEqual(data.textLines, null);
+ assert.strictEqual(data.htmlLines, null);
+ assert.strictEqual(data.htmlContent, null);
+ });
});
describe("owner pages", () => {