-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #4 from browserup/sys32
Add system path check to start command
- Loading branch information
Showing
3 changed files
with
60 additions
and
39 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
export function isSystemDirectory(dirPath) { | ||
// Normalize the directory path to lower case and ensure it ends with a slash | ||
dirPath = dirPath.toLowerCase().replace(/\\+/g, '/'); | ||
if (!dirPath.endsWith('/')) { | ||
dirPath += '/'; | ||
} | ||
|
||
// Known system directories for Windows and Linux | ||
const windowsSystemDirs = [ | ||
'c:/', | ||
'c:/windows/', | ||
'c:/program files/', | ||
'c:/program files (x86)/', | ||
'c:/programdata/', | ||
'c:/users/', | ||
'c:/windows/system32/', | ||
'c:/windows/syswow64/' | ||
]; | ||
|
||
const linuxSystemDirs = [ | ||
'/', | ||
'/bin/', | ||
'/sbin/', | ||
'/usr/', | ||
'/usr/bin/', | ||
'/usr/sbin/', | ||
'/etc/', | ||
'/var/', | ||
'/var/lib/', | ||
'/opt/', | ||
'/lib/', | ||
'/lib64/', | ||
'/tmp/', | ||
'/boot/', | ||
'/home/', | ||
'/root/', | ||
'/mnt/', | ||
'/media/', | ||
'/srv/' | ||
]; | ||
|
||
// Combine both lists | ||
const systemDirs = windowsSystemDirs.concat(linuxSystemDirs); | ||
|
||
// Check if the directory path is an exact match to any known system directory | ||
return systemDirs.includes(dirPath); | ||
} |