mirror of
https://github.com/bitwarden/jslib
synced 2025-12-19 17:53:48 +00:00
Simplify check of url for null and whitespace
This commit is contained in:
@@ -188,14 +188,12 @@ export class Utils {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static getHostname(uriString: string): string {
|
static getHostname(uriString: string): string {
|
||||||
if (uriString == null) {
|
if (Utils.isNullOrWhitespace(uriString)) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
uriString = uriString.trim();
|
uriString = uriString.trim();
|
||||||
if (uriString === '') {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
// Does uriString contain invalid characters
|
// Does uriString contain invalid characters
|
||||||
// TODO Needs to possibly be extended, although '!' is a reserved character
|
// TODO Needs to possibly be extended, although '!' is a reserved character
|
||||||
if (uriString.indexOf('!') > 0) {
|
if (uriString.indexOf('!') > 0) {
|
||||||
@@ -220,14 +218,11 @@ export class Utils {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static getDomain(uriString: string): string {
|
static getDomain(uriString: string): string {
|
||||||
if (uriString == null) {
|
if (Utils.isNullOrWhitespace(uriString)) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
uriString = uriString.trim();
|
uriString = uriString.trim();
|
||||||
if (uriString === '') {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (uriString.startsWith('data:')) {
|
if (uriString.startsWith('data:')) {
|
||||||
return null;
|
return null;
|
||||||
@@ -308,14 +303,11 @@ export class Utils {
|
|||||||
|
|
||||||
|
|
||||||
static getUrl(uriString: string): URL {
|
static getUrl(uriString: string): URL {
|
||||||
if (uriString == null) {
|
if (this.isNullOrWhitespace(uriString)) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
uriString = uriString.trim();
|
uriString = uriString.trim();
|
||||||
if (uriString === '') {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
let url = Utils.getUrlObject(uriString);
|
let url = Utils.getUrlObject(uriString);
|
||||||
if (url == null) {
|
if (url == null) {
|
||||||
|
|||||||
Reference in New Issue
Block a user