diff --git a/src/__tests__/providers/File/index.test.ts b/src/__tests__/providers/File/index.test.ts
index 83aad30..9ca759f 100644
--- a/src/__tests__/providers/File/index.test.ts
+++ b/src/__tests__/providers/File/index.test.ts
@@ -25,33 +25,33 @@ describe("FileDataProvider", () => {
{
content:
"id, column1, column2, column3\n1, test, 11111, test test\n2, test2 test2, 22222, test\n3, test3, 33333, test test test",
- metadata: { sourceURL: expect.stringMatching(/^#FILE_\d+$/) },
+ metadata: { sourceURL: expect.stringMatching(/^#FILE_\d+$/), title: "test.csv" },
provider: "file",
type: "csv",
},
{
content:
"# This is a test markdown file\n\nThis file is used for testing purposes. Below is a list of items:\n\n- Item 1\n- Item 2\n- Item 3\n\nEnd of file.\n",
- metadata: { sourceURL: expect.stringMatching(/^#FILE_\d+$/) },
+ metadata: { sourceURL: expect.stringMatching(/^#FILE_\d+$/), title: "test.md" },
provider: "file",
type: "md",
},
{
content: expect.stringContaining("Dummy PDF file"),
- metadata: { sourceURL: expect.stringMatching(/^#FILE_\d+$/) },
+ metadata: { sourceURL: expect.stringMatching(/^#FILE_\d+$/), title: "test.pdf" },
provider: "file",
type: "pdf",
},
{
content: "This is a test file.\n",
- metadata: { sourceURL: expect.stringMatching(/^#FILE_\d+$/) },
+ metadata: { sourceURL: expect.stringMatching(/^#FILE_\d+$/), title: "test.txt" },
provider: "file",
type: "txt",
},
{
content:
'\n\n \n 1\n test\n 11111\n test test\n \n \n 2\n test2 test2\n 22222\n test\n \n \n 3\n test3\n 33333\n test test test\n \n\n',
- metadata: { sourceURL: expect.stringMatching(/^#FILE_\d+$/) },
+ metadata: { sourceURL: expect.stringMatching(/^#FILE_\d+$/), title: "test.xml" },
provider: "file",
type: "xml",
},
@@ -83,7 +83,7 @@ describe("FileDataProvider", () => {
expect(documentsByURL).toContainEqual({
content:
"id, column1, column2, column3\n1, test, 11111, test test\n2, test2 test2, 22222, test\n3, test3, 33333, test test test\n",
- metadata: { sourceURL: optionsURLs.urls[0] },
+ metadata: { sourceURL: optionsURLs.urls[0], title: "test.csv" },
provider: "file",
type: "csv",
});
@@ -91,19 +91,19 @@ describe("FileDataProvider", () => {
content: expect.stringContaining(
"# This is a test markdown file\n\nThis file is used for testing purposes. Below is a list of items:\n\n- Item 1\n- Item 2\n- Item 3\n\nEnd of file.\n"
),
- metadata: { sourceURL: optionsURLs.urls[1] },
+ metadata: { sourceURL: optionsURLs.urls[1], title: "test.md" },
provider: "file",
type: "md",
});
expect(documentsByURL).toContainEqual({
content: expect.stringContaining("Dummy PDF file"),
- metadata: { sourceURL: optionsURLs.urls[2] },
+ metadata: { sourceURL: optionsURLs.urls[2], title: "test%20%281%29.pdf" },
provider: "file",
type: "pdf",
});
expect(documentsByURL).toContainEqual({
content: expect.stringContaining("This is a test file."),
- metadata: { sourceURL: optionsURLs.urls[3] },
+ metadata: { sourceURL: optionsURLs.urls[3], title: "test.txt" },
provider: "file",
type: "txt",
});
@@ -111,7 +111,7 @@ describe("FileDataProvider", () => {
content: expect.stringContaining(
'\n\n \n 1\n test\n 11111\n test test\n \n \n 2\n test2 test2\n 22222\n test\n \n \n 3\n test3\n 33333\n test test test\n \n'
),
- metadata: { sourceURL: optionsURLs.urls[4] },
+ metadata: { sourceURL: optionsURLs.urls[4], title: "test.xml" },
provider: "file",
type: "xml",
});
diff --git a/src/providers/File/index.ts b/src/providers/File/index.ts
index f4e2369..9ab6800 100644
--- a/src/providers/File/index.ts
+++ b/src/providers/File/index.ts
@@ -65,6 +65,7 @@ export class FileDataProvider implements DataProvider {
content,
metadata: {
sourceURL: "#FILE_" + randomNumber.toString(),
+ title: this.files[i].includes('/') ? this.files[i].split('/').pop() : this.files[i],
},
provider: "file",
type: fileType,
@@ -108,6 +109,7 @@ export class FileDataProvider implements DataProvider {
content,
metadata: {
sourceURL: this.urls[i],
+ title: this.urls[i].includes('/') ? this.urls[i].split('/').pop() : this.urls[i],
},
provider: "file",
type: fileType,