mirror of
https://github.com/Nezumi-2711/next-gdrive-index.git
synced 2026-09-22 13:38:38 +00:00
🐞 fix: Length is undefined when changing route
This commit is contained in:
@@ -1,6 +0,0 @@
|
||||
import type { NextRequest } from "next/server";
|
||||
import { NextResponse } from "next/server";
|
||||
|
||||
export function middleware(request: NextRequest) {
|
||||
return NextResponse.next();
|
||||
}
|
||||
@@ -43,7 +43,7 @@ export default function FilePathPage(props: FilePathPageProps) {
|
||||
useEffect(() => {
|
||||
setIsLoadingData(true);
|
||||
|
||||
const lastPathMimeType = props.mappedEncryptedPath[props.mappedEncryptedPath.length - 1].mimeType;
|
||||
const lastPathMimeType = props.mappedEncryptedPath[(props.mappedEncryptedPath.length ?? 1) - 1].mimeType;
|
||||
let isLastPathFile = false;
|
||||
if (lastPathMimeType === "application/vnd.google-apps.folder") {
|
||||
isLastPathFile = false;
|
||||
@@ -73,7 +73,7 @@ export default function FilePathPage(props: FilePathPageProps) {
|
||||
Promise.all([_getPassword, _getData, _getReadme])
|
||||
.then(async ([passwordData, fileData, readmeData]) => {
|
||||
// Check password
|
||||
if (passwordData.data.data.length) {
|
||||
if (passwordData.data.data && passwordData.data.data.length) {
|
||||
let isPathProtected = true;
|
||||
const savedPasswordCookie =
|
||||
document.cookie.split(";").find((cookie) => cookie.startsWith(`${Constant.cookies_SitePassword}=`)) ??
|
||||
@@ -118,7 +118,7 @@ export default function FilePathPage(props: FilePathPageProps) {
|
||||
return (
|
||||
<LoaderLayout
|
||||
seo={{
|
||||
title: props.mappedEncryptedPath[props.mappedEncryptedPath.length - 1].name,
|
||||
title: props.mappedEncryptedPath[(props.mappedEncryptedPath.length ?? 1) - 1].name,
|
||||
}}
|
||||
>
|
||||
{isLoadingData ? (
|
||||
@@ -156,7 +156,7 @@ export default function FilePathPage(props: FilePathPageProps) {
|
||||
data={data}
|
||||
isProtected={false}
|
||||
isFileProtected={isFileProtected}
|
||||
encryptedId={props.mappedEncryptedPath[props.mappedEncryptedPath.length - 1].id}
|
||||
encryptedId={props.mappedEncryptedPath[(props.mappedEncryptedPath.length ?? 1) - 1].id}
|
||||
/>
|
||||
) : (
|
||||
<ExplorerLayout
|
||||
@@ -165,7 +165,7 @@ export default function FilePathPage(props: FilePathPageProps) {
|
||||
readmeFile={readmeFile}
|
||||
isProtected={false}
|
||||
isFileProtected={isFileProtected}
|
||||
encryptedId={props.mappedEncryptedPath[props.mappedEncryptedPath.length - 1].id}
|
||||
encryptedId={props.mappedEncryptedPath[(props.mappedEncryptedPath.length ?? 1) - 1].id}
|
||||
/>
|
||||
)}
|
||||
</>
|
||||
|
||||
Reference in New Issue
Block a user