Skip to content

Commit

Permalink
Support of .jsonl files implemented (#816)
Browse files Browse the repository at this point in the history
* Support of .jsonl files provided

* jsonl file appears as json icon in modal window
  • Loading branch information
mulla028 authored Feb 4, 2025
1 parent bcb726d commit 269efe4
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/components/FileIcon.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ const FILE_ICON_MAP: Record<string, IconType> = {
xlsx: BsFiletypeXls,
// Code
json: BsFiletypeJson,
jsonl: BsFiletypeJson,
md: BsFiletypeMd,
};

Expand Down
9 changes: 9 additions & 0 deletions src/hooks/use-file-import.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ const FILE_EXTENSIONS: Record<string, string> = {
yaml: "yaml",
yml: "yaml",
json: "json",
jsonl: "json",
xml: "xml",
r: "r",
csv: "csv",
Expand Down Expand Up @@ -109,6 +110,8 @@ const MIME_TYPES: Record<string, string> = {
"application/json": "json",
"text/xml": "xml",
"application/xml": "xml",
"application/x-jsonlines": "json",
"text/x-jsonlines": "json",
};

function detectLanguage(filename: string, mimeType: string): string | undefined {
Expand Down Expand Up @@ -152,6 +155,12 @@ async function processFile(
return contents;
}

if (file.name.endsWith(".jsonl")) {
const text = await readTextFile(file);
assertContents(text);
return formatTextContent(file.name, "application/x-jsonlines", text);
}

if (file.type === "application/markdown" || file.type === "text/markdown") {
const contents = await readTextFile(file);
assertContents(contents);
Expand Down

0 comments on commit 269efe4

Please sign in to comment.