mirror of
https://github.com/DustinBrett/daedalOS.git
synced 2026-01-15 12:15:02 +00:00
Don't allow invalid names when mapping drive
This commit is contained in:
@@ -19,6 +19,7 @@ import useAsyncFs from "contexts/fileSystem/useAsyncFs";
|
||||
import type { UpdateFiles } from "contexts/session/types";
|
||||
import { basename, dirname, extname, isAbsolute, join } from "path";
|
||||
import { useCallback, useEffect, useState } from "react";
|
||||
import { DEFAULT_MAPPED_NAME, INVALID_FILE_CHARACTERS } from "utils/constants";
|
||||
|
||||
type FilePasteOperations = Record<string, "copy" | "move">;
|
||||
|
||||
@@ -117,8 +118,12 @@ const useFileSystemContextState = (): FileSystemContextState => {
|
||||
return;
|
||||
}
|
||||
|
||||
rootFs?.mount?.(join(directory, handle.name), newFs);
|
||||
resolve(handle.name);
|
||||
const mappedName =
|
||||
handle.name.replace(INVALID_FILE_CHARACTERS, "").trim() ||
|
||||
DEFAULT_MAPPED_NAME;
|
||||
|
||||
rootFs?.mount?.(join(directory, mappedName), newFs);
|
||||
resolve(mappedName);
|
||||
addFileSystemHandle(directory, handle);
|
||||
});
|
||||
} else {
|
||||
|
||||
@@ -19,6 +19,8 @@ export const DEFAULT_WINDOW_SIZE: Size = {
|
||||
width: 405,
|
||||
};
|
||||
|
||||
export const DEFAULT_MAPPED_NAME = "Share";
|
||||
|
||||
export const FOCUSABLE_ELEMENT = { tabIndex: -1 };
|
||||
|
||||
export const FS_HANDLES = "FileSystemAccessHandles";
|
||||
|
||||
Reference in New Issue
Block a user