util: isValidRef method

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

View File

@@ -75,6 +75,18 @@ export class Util {
return url.protocol === 'http:' || url.protocol === 'https:';
}
public static isValidRef(refStr: string): boolean {
if (Util.isValidURL(refStr)) {
return true;
}
for (const prefix of ['git://', 'github.com/', 'git@']) {
if (refStr.startsWith(prefix)) {
return true;
}
}
return false;
}
public static async powershellCommand(script: string, params?: Record<string, string>) {
const powershellPath: string = await io.which('powershell', true);
const escapedScript = script.replace(/'/g, "''").replace(/"|\n|\r/g, '');