1
0
mirror of https://github.com/bitwarden/browser.git synced 2024-11-27 12:36:14 +01:00

null or whitespace util

This commit is contained in:
Kyle Spearrin 2019-01-15 11:34:35 -05:00
parent f4c4f28026
commit cb7336c0e8
2 changed files with 5 additions and 1 deletions

View File

@ -155,7 +155,7 @@ export abstract class BaseImporter {
}
protected isNullOrWhitespace(str: string): boolean {
return str == null || typeof str !== 'string' || str.trim() === '';
return Utils.isNullOrWhitespace(str);
}
protected getValueOrDefault(str: string, defaultValue: string = null): string {

View File

@ -236,6 +236,10 @@ export class Utils {
};
}
static isNullOrWhitespace(str: string): boolean {
return str == null || typeof str !== 'string' || str.trim() === '';
}
private static validIpAddress(ipString: string): boolean {
// tslint:disable-next-line
const ipRegex = /^(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$/;