Add /e prefix to file path

This commit is contained in:
mbaharip
2024-04-06 23:30:20 +07:00
parent 6e9dc471b4
commit 49f9b3977b
7 changed files with 24 additions and 18 deletions
+3 -1
View File
@@ -42,7 +42,9 @@ type Props = {
export default function FileGrid({ data }: Props) {
const pathname = usePathname();
const filePath = useMemo<string>(() => {
const path = [pathname, encodeURIComponent(data.name)]
const currentPath = pathname.startsWith("/e") ? pathname : `/e${pathname}`;
// Set to pathname to remove the /e prefix
const path = [currentPath, encodeURIComponent(data.name)]
.join("/")
.replace(/\/+/g, "/");
+3 -1
View File
@@ -42,7 +42,9 @@ export default function FileList({ data }: Props) {
const pathname = usePathname();
const filePath = useMemo<string>(() => {
const path = [pathname, encodeURIComponent(data.name)]
const currentPath = pathname.startsWith("/e") ? pathname : `/e${pathname}`;
// Set to pathname to remove the /e prefix
const path = [currentPath, encodeURIComponent(data.name)]
.join("/")
.replace(/\/+/g, "/");
@@ -1,4 +1,5 @@
import { NextRequest, NextResponse } from "next/server";
import {
CheckDownloadToken,
CheckPassword,
+1
View File
@@ -1,4 +1,5 @@
import { NextRequest, NextResponse } from "next/server";
import { CheckPassword, CheckPaths, GetFile } from "~/app/actions";
import { decryptData } from "~/utils/encryptionHelper/hash";
@@ -11,19 +11,19 @@ import { decryptData } from "~/utils/encryptionHelper/hash";
import gdrive from "~/utils/gdriveInstance";
import { getFileType } from "~/utils/previewHelper";
import FileBrowser from "../@explorer";
import Header from "../@header";
import HeaderButton from "../@header.button";
import Markdown from "../@markdown";
import Password from "../@password";
import PreviewAction from "../@preview.action";
import PreviewAudio from "../@preview.audio";
import PreviewDoc from "../@preview.doc";
import PreviewImage from "../@preview.image";
import PreviewManga from "../@preview.manga";
import PreviewRich from "../@preview.rich";
import PreviewUnknown from "../@preview.unknown";
import PreviewVideo from "../@preview.video";
import FileBrowser from "../../@explorer";
import Header from "../../@header";
import HeaderButton from "../../@header.button";
import Markdown from "../../@markdown";
import Password from "../../@password";
import PreviewAction from "../../@preview.action";
import PreviewAudio from "../../@preview.audio";
import PreviewDoc from "../../@preview.doc";
import PreviewImage from "../../@preview.image";
import PreviewManga from "../../@preview.manga";
import PreviewRich from "../../@preview.rich";
import PreviewUnknown from "../../@preview.unknown";
import PreviewVideo from "../../@preview.video";
import {
CheckPassword,
CheckPaths,
@@ -31,7 +31,7 @@ import {
GetFile,
GetFiles,
GetReadme,
} from "../actions";
} from "../../actions";
export const revalidate = 300;
export const dynamic = "force-dynamic";
+1 -1
View File
@@ -10,7 +10,7 @@ import Markdown from "./@markdown";
import { GetFiles, GetReadme } from "./actions";
export const revalidate = 300;
export const dynamic = 'force-dynamic'
export const dynamic = "force-dynamic";
export default async function RootPage() {
const [data, readme] = await Promise.all([