-
Notifications
You must be signed in to change notification settings - Fork 0
/
checks.js
37 lines (30 loc) · 1006 Bytes
/
checks.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
//import os from 'os';
import 'dotenv/config';
import chalk from 'chalk';
export function checkpath(filteredpath) {
console.log(filteredpath);
let substrings = ["Windows", "Program Files", "appdata", "pictures"];
checkwhitelist(filteredpath)
const characterCheck = /^[a-zA-Z0-9_\/.\-\s:\\]+$/;
if (!characterCheck.test(filteredpath)) {
console.log(`Unsafe String Detected!`);
process.exit(2);
}
substrings.forEach(substring => {
if (filteredpath.includes(substring)) {
console.log(`Unsafe String Detected`);
process.exit(3);
}
});
console.log("path checked");
}
function checkwhitelist(filteredPath) {
if (filteredPath.startsWith(process.env.vaultDomain)) {
console.log("Path Checked");
}
else{
console.log(chalk.red("Incorrect location to obsidian folder"))
console.log(chalk.green("to set your Obsidian folder domain, run obsmoc vault"))
process.exit(7)
}
}