util: fix isValidURL

Signed-off-by: CrazyMax <crazy-max@users.noreply.github.com>
This commit is contained in:
CrazyMax
2023-03-25 16:01:10 +01:00
parent b0518231d0
commit 9b9ff70b75
2 changed files with 8 additions and 4 deletions

View File

@@ -65,13 +65,14 @@ export class Util {
}
}
public static isValidUrl(url: string): boolean {
public static isValidURL(urlStr: string): boolean {
let url;
try {
new URL(url);
url = new URL(urlStr);
} catch (e) {
return false;
}
return true;
return url.protocol === 'http:' || url.protocol === 'https:';
}
public static async powershellCommand(script: string, params?: Record<string, string>) {