mirror of
https://github.com/khoaliber/khoj.git
synced 2026-03-02 21:19:12 +00:00
Handle null reference exceptions when rendering files context
This commit is contained in:
@@ -467,9 +467,12 @@ export function constructAllReferences(
|
|||||||
if (contextData) {
|
if (contextData) {
|
||||||
let localContextReferences = contextData.map((context) => {
|
let localContextReferences = contextData.map((context) => {
|
||||||
if (!context.compiled && context.compiled !== "") {
|
if (!context.compiled && context.compiled !== "") {
|
||||||
const fileContent = context as unknown as string;
|
const raw = context as unknown;
|
||||||
const title = fileContent.split("\n")[0];
|
const fileContent = typeof raw === "string" ? raw : raw == null ? "" : String(raw);
|
||||||
const content = fileContent.split("\n").slice(1).join("\n");
|
|
||||||
|
const lines = fileContent.split("\n");
|
||||||
|
const title = lines[0] && lines[0].trim() ? lines[0] : "(untitled)";
|
||||||
|
const content = lines.slice(1).join("\n");
|
||||||
return {
|
return {
|
||||||
title: title,
|
title: title,
|
||||||
content: content,
|
content: content,
|
||||||
|
|||||||
Reference in New Issue
Block a user