diff --git a/components/FileListing.tsx b/components/FileListing.tsx
index d4b60c7..94ba9ea 100644
--- a/components/FileListing.tsx
+++ b/components/FileListing.tsx
@@ -12,7 +12,7 @@ import { useTranslation } from 'next-i18next'
import useLocalStorage from '../utils/useLocalStorage'
import { getPreviewType, preview } from '../utils/getPreviewType'
import { useProtectedSWRInfinite } from '../utils/fetchWithSWR'
-import { getFileIcon } from '../utils/getFileIcon'
+import { getExtension, getFileIcon } from '../utils/getFileIcon'
import {
DownloadingToast,
downloadMultipleFiles,
@@ -66,10 +66,20 @@ const renderEmoji = (name: string) => {
const emoji = emojiRegex().exec(name)
return { render: emoji && !emoji.index, emoji }
}
-export const formatChildName = (name: string) => {
+const formatChildName = (name: string) => {
const { render, emoji } = renderEmoji(name)
return render ? name.replace(emoji ? emoji[0] : '', '').trim() : name
}
+export const ChildName: FC<{ name: string }> = ({ name }) => {
+ const original = formatChildName(name)
+ const extension = getExtension(original)
+ const prename = original.substring(0, original.length - extension.length)
+ return (
+
+ {prename}
+
+ )
+}
export const ChildIcon: FC<{ child: OdFolderChildren }> = ({ child }) => {
const { render, emoji } = renderEmoji(child.name)
return render ? (
@@ -364,11 +374,7 @@ const FileListing: FC<{ query?: ParsedUrlQuery }> = ({ query }) => {
if ('file' in responses[0] && responses.length === 1) {
const file = responses[0].file as OdFileObject
- const downloadUrl = file['@microsoft.graph.downloadUrl']
- const fileName = file.name
- const fileExtension = fileName.slice(((fileName.lastIndexOf('.') - 1) >>> 0) + 2).toLowerCase()
-
- const previewType = getPreviewType(fileExtension, { video: Boolean(file.video) })
+ const previewType = getPreviewType(getExtension(file.name), { video: Boolean(file.video) })
if (previewType) {
switch (previewType) {
diff --git a/components/FolderGridLayout.tsx b/components/FolderGridLayout.tsx
index 2daec92..312cca2 100644
--- a/components/FolderGridLayout.tsx
+++ b/components/FolderGridLayout.tsx
@@ -9,7 +9,7 @@ import { useTranslation } from 'next-i18next'
import { getBaseUrl } from '../utils/getBaseUrl'
import { formatModifiedDateTime } from '../utils/fileDetails'
import { getReadablePath } from '../utils/getReadablePath'
-import { Checkbox, ChildIcon, Downloading, formatChildName } from './FileListing'
+import { Checkbox, ChildIcon, ChildName, Downloading } from './FileListing'
const GridItem = ({ c, path }: { c: OdFolderChildren; path: string }) => {
// We use the generated medium thumbnail for rendering preview images (excluding folders)
@@ -43,7 +43,7 @@ const GridItem = ({ c, path }: { c: OdFolderChildren; path: string }) => {