Adding more directory-related unit tests. Several more bug fixes and QoL improvements

This commit is contained in:
danielyxie
2019-05-14 01:35:37 -07:00
parent 1775ea86ff
commit fef7aaba8f
24 changed files with 423 additions and 85 deletions
+3 -2
View File
@@ -37,8 +37,8 @@ export function removeTrailingSlash(s: string): string {
*/
export function isValidFilename(filename: string): boolean {
// Allows alphanumerics, hyphens, underscores.
// Must have a file exntesion
const regex = /^[.a-zA-Z0-9_-]+[.][.a-zA-Z0-9_-]+$/;
// Must have a file extension
const regex = /^[.a-zA-Z0-9_-]+[.][.a-zA-Z0-9]+$/;
// match() returns null if no match is found
return filename.match(regex) != null;
@@ -98,6 +98,7 @@ export function isValidDirectoryPath(path: string): boolean {
* proper formatting. It dose NOT check if the file actually exists on Terminal
*/
export function isValidFilePath(path: string): boolean {
if (path == null || typeof path !== "string") { return false; }
let t_path = path;
// Impossible for filename to have less than length of 3