Skip to content

Commit

Permalink
chore: Simplify the file path reg exp
Browse files Browse the repository at this point in the history
  • Loading branch information
alexhua committed Nov 21, 2023
1 parent 97c4e1a commit 44b34b8
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
4 changes: 2 additions & 2 deletions js/options.js
Original file line number Diff line number Diff line change
Expand Up @@ -77,9 +77,9 @@ var Configs =
input.parentElement.classList.remove('tool-tip');
input.parentElement.removeAttribute("tooltip-content");
let result = validator[input.type](input.value);
if (result == "VALID") {
if (result == "VALID" || result === true) {
input.classList.add("is-valid");
} else if (input.value && result == "INVALID") {
} else if (input.value && (result == "INVALID" || result === false)) {
input.classList.add("is-invalid");
} else if (result == "WARNING") {
input.classList.add("is-valid", "is-warning");
Expand Down
4 changes: 2 additions & 2 deletions js/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -245,10 +245,10 @@ class Utils {
static validateFilePath(filePath) {
let regexp = ''
if (filePath.startsWith('/')) {
regexp = /^\/([-\u4e00-\u9fa5\w\s.()~!@#$%^&()\[\]{}+=]+\/?)*$/;
regexp = /^\/([^\s?*"'\\:;|<>/]+\/?)*$/;
}
else {
regexp = /^([a-zA-Z]:\\)([-\u4e00-\u9fa5\w\s.()~!@#$%^&()\[\]{}+=]+\\?)*$/;
regexp = /^([a-zA-Z]:\\?)((?<=\\)[^<>/\\?*":|]+\\?)*$/;
}
return regexp.test(filePath);
}
Expand Down
2 changes: 1 addition & 1 deletion manifest.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "__MSG_appName__",
"short_name": "AE",
"version": "2.2.3",
"version": "2.2.4",
"manifest_version": 3,
"minimum_chrome_version": "100.0.0",
"default_locale": "en",
Expand Down

0 comments on commit 44b34b8

Please sign in to comment.