Skip to content

Commit 8e8bc81

Browse files
committed
Hide search feature when page is opened from file:// protocol
Search relies on fetch() to load page content, which doesn't work from file:// due to CORS restrictions. Now returns early before showing the search UI when window.location.protocol is 'file:'. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> Transcript: https://gistpreview.github.io/?701ec658eede1bd0023f82fdb9a46229/index.html Refs #16 (comment) Refs #15
1 parent 7fa9c36 commit 8e8bc81

File tree

3 files changed

+9
-0
lines changed

3 files changed

+9
-0
lines changed

src/claude_code_transcripts/templates/search.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@
1212

1313
if (!searchBox || !modal) return;
1414

15+
// Hide search on file:// protocol (doesn't work due to CORS restrictions)
16+
if (window.location.protocol === 'file:') return;
17+
1518
// Show search box (progressive enhancement)
1619
searchBox.style.display = 'flex';
1720

tests/__snapshots__/test_generate_html/TestGenerateHtml.test_generates_index_html.html

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -215,6 +215,9 @@ <h1>Claude Code transcript</h1>
215215

216216
if (!searchBox || !modal) return;
217217

218+
// Hide search on file:// protocol (doesn't work due to CORS restrictions)
219+
if (window.location.protocol === 'file:') return;
220+
218221
// Show search box (progressive enhancement)
219222
searchBox.style.display = 'flex';
220223

tests/__snapshots__/test_generate_html/TestParseSessionFile.test_jsonl_generates_html.html

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -206,6 +206,9 @@ <h1>Claude Code transcript</h1>
206206

207207
if (!searchBox || !modal) return;
208208

209+
// Hide search on file:// protocol (doesn't work due to CORS restrictions)
210+
if (window.location.protocol === 'file:') return;
211+
209212
// Show search box (progressive enhancement)
210213
searchBox.style.display = 'flex';
211214

0 commit comments

Comments
 (0)