🔀 merge dev

This commit is contained in:
Tw93
2023-04-08 20:29:02 +08:00
38 changed files with 3162 additions and 973 deletions

13
bin/utils/validate.ts vendored
View File

@@ -1,5 +1,6 @@
import * as Commander from 'commander';
import { normalizeUrl } from './url.js';
import fs from 'fs';
export function validateNumberInput(value: string) {
const parsedValue = Number(value);
@@ -10,9 +11,13 @@ export function validateNumberInput(value: string) {
}
export function validateUrlInput(url: string) {
try {
return normalizeUrl(url);
} catch (error) {
throw new Commander.InvalidArgumentError(error.message);
if(!fs.existsSync(url)) {
try {
return normalizeUrl(url)
} catch (error) {
throw new Commander.InvalidArgumentError(error.message);
}
} else {
return url;
}
}