🔀 merge dev
This commit is contained in:
13
bin/utils/validate.ts
vendored
13
bin/utils/validate.ts
vendored
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user