1
0
mirror of https://github.com/bitwarden/browser synced 2025-12-18 01:03:35 +00:00

allow launching URLs without protocol than end with tld

This commit is contained in:
Kyle Spearrin
2019-01-07 10:33:13 -05:00
parent 1542dd45d3
commit e7464785e1
4 changed files with 21 additions and 4 deletions

View File

@@ -12,6 +12,7 @@ export class Utils {
static isBrowser = true;
static isMobileBrowser = false;
static global: any = null;
static tldEndingRegex = /.*\.(com|net|org|edu|uk|gov|ca|de|jp|fr|au|ru|ch|io|es|us|co|xyz|info|ly|mil)$/;
static init() {
if (Utils.inited) {
@@ -175,7 +176,13 @@ export class Utils {
return null;
}
if (uriString.startsWith('http://') || uriString.startsWith('https://')) {
let httpUrl = uriString.startsWith('http://') || uriString.startsWith('https://');
if (!httpUrl && Utils.tldEndingRegex.test(uriString)) {
uriString = 'http://' + uriString;
httpUrl = true;
}
if (httpUrl) {
try {
const url = Utils.getUrlObject(uriString);
if (url.hostname === 'localhost' || Utils.validIpAddress(url.hostname)) {