From a2e06f0a217b12d92cecdad77c20de88037f9912 Mon Sep 17 00:00:00 2001 From: pacien Date: Tue, 19 May 2020 21:05:28 +0200 Subject: viewer/navigation: factorise item file name extraction --- viewer/src/components/LdDownload.vue | 10 +++------- viewer/src/services/navigation.ts | 7 +++++++ 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/viewer/src/components/LdDownload.vue b/viewer/src/components/LdDownload.vue index aea4123..d7dfb7d 100644 --- a/viewer/src/components/LdDownload.vue +++ b/viewer/src/components/LdDownload.vue @@ -30,21 +30,17 @@ diff --git a/viewer/src/services/navigation.ts b/viewer/src/services/navigation.ts index 7d1ae50..f96904d 100644 --- a/viewer/src/services/navigation.ts +++ b/viewer/src/services/navigation.ts @@ -81,4 +81,11 @@ export default class Navigation { return "file"; } } + + // Get the file name of an item, without its cache timestamp + public static getFileName(item: Gallery.Item): string { + if (item.properties.type === "directory") return item.title; + const timeStamped = item.properties.resource.split("/").pop() ?? ""; + return timeStamped.split("?")[0]; + } } -- cgit v1.2.3