Skip to content

Build your personal knowledge base with Trilium Notes

feat(gpx): title an imported track without its extension

Elian Doran3a9bd92d9761
diff --git a/apps/client/src/widgets/collections/geomap/api.spec.ts b/apps/client/src/widgets/collections/geomap/api.spec.ts
index 5da40868ee..c239763987 100644
--- a/apps/client/src/widgets/collections/geomap/api.spec.ts
+++ b/apps/client/src/widgets/collections/geomap/api.spec.ts
@@ -100,7 +100,8 @@ describe("geo map api", () => {
expect(created).toEqual({ noteId: "created" });
expect(createNote).toHaveBeenCalledWith(parent.noteId, expect.objectContaining({
- title: "sunday-ride.gpx",
+ // Titled without the extension, as an imported file is; the whole name stays on the label.
+ title: "sunday-ride",
content: "<gpx><trk/></gpx>",
type: "file",
// Pinned rather than read off the file: a browser reports no type for a .gpx, and this
diff --git a/apps/client/src/widgets/collections/geomap/api.ts b/apps/client/src/widgets/collections/geomap/api.ts
index 1c74f184e1..069947aab3 100644
--- a/apps/client/src/widgets/collections/geomap/api.ts
+++ b/apps/client/src/widgets/collections/geomap/api.ts
@@ -71,7 +71,9 @@ export async function removeFromMap(note: FNote, mapNote: FNote) {
*/
export async function importGpxTrack(parentNote: FNote, file: File) {
const { note } = await note_create.createNote(parentNote.noteId, {
- title: file.name,
+ // Without its extension, as an imported file is titled (see getNoteTitle in core). The whole
+ // name is kept on the label below.
+ title: file.name.replace(/\.gpx$/i, ""),
content: await file.text(),
type: "file",
mime: "application/gpx+xml",
diff --git a/packages/trilium-core/src/services/utils/index.spec.ts b/packages/trilium-core/src/services/utils/index.spec.ts
index 13ceebf4fd..3c18292570 100644
--- a/packages/trilium-core/src/services/utils/index.spec.ts
+++ b/packages/trilium-core/src/services/utils/index.spec.ts
@@ -312,6 +312,7 @@ describe("#removeFileExtension", () => {
[ "w/ 'test.htm' it should strip '.htm'", [ "test.htm" ], "test" ],
[ "w/ 'test.xlsx' it should strip '.xlsx'", [ "test.xlsx" ], "test" ],
[ "w/ 'test.csv' it should strip '.csv'", [ "test.csv" ], "test" ],
+ [ "w/ 'test.gpx' it should strip '.gpx'", [ "test.gpx" ], "test" ],
[ "w/ 'test.zip' it should NOT strip '.zip'", [ "test.zip" ], "test.zip" ]
];
diff --git a/packages/trilium-core/src/services/utils/index.ts b/packages/trilium-core/src/services/utils/index.ts
index ec6e69f5fe..b96cac468e 100644
--- a/packages/trilium-core/src/services/utils/index.ts
+++ b/packages/trilium-core/src/services/utils/index.ts
@@ -290,6 +290,7 @@ export function removeFileExtension(filePath: string, mime?: string) {
case ".pdf":
case ".xlsx":
case ".csv":
+ case ".gpx":
case ".triliumsheet":
return filePath.substring(0, filePath.length - extension.length);
default: