Skip to content

Usenet streaming with a WebDAV server and a SABnzbd-compatible API

C#

Added extension query param to end of `Dav Explore` links.

nzbdav-dev507404347f1a
diff --git a/frontend/app/routes/explore/route.tsx b/frontend/app/routes/explore/route.tsx
index ad5a3d6c..21c8427e 100644
--- a/frontend/app/routes/explore/route.tsx
+++ b/frontend/app/routes/explore/route.tsx
@@ -60,9 +60,11 @@ function Body(props: ExplorePageData) {
}, [location.pathname]);
const getFilePath = useCallback((file: ExploreFile) => {
- var pathname = getWebdavPath(location.pathname);
- var relativePath = getRelativePath(pathname, encodeURIComponent(file.name));
- return `/view/${relativePath}?downloadKey=${file.downloadKey}`;
+ const pathname = getWebdavPath(location.pathname);
+ const relativePath = getRelativePath(pathname, encodeURIComponent(file.name));
+ const extension = getExtension(file.name);
+ const extensionQueryParam = extension ? `&extension=${extension}` : '';
+ return `/view/${relativePath}?downloadKey=${file.downloadKey}${extensionQueryParam}`;
}, [location.pathname]);
return (
@@ -92,6 +94,12 @@ function Body(props: ExplorePageData) {
);
}
+function getExtension(filename: string): string | undefined {
+ const lastDotIndex = filename.lastIndexOf('.');
+ if (lastDotIndex === -1 || lastDotIndex === 0) return undefined;
+ return filename.slice(lastDotIndex);
+}
+
function getIcon(file: ExploreFile) {
if (file.name.toLowerCase().endsWith(".mkv")) return styles["video-icon"];
if (file.mimeType && file.mimeType.startsWith("video")) return styles["video-icon"];