mirror of
https://github.com/bitwarden/browser
synced 2025-12-15 07:43:35 +00:00
Improve URL parsing (#411)
* Check hostname is valid in getDomain * fix linting * Update noop implementation * Fix tests * Fix tests
This commit is contained in:
@@ -1,3 +1,7 @@
|
||||
export function getDomain(host: string): string | null {
|
||||
return null;
|
||||
}
|
||||
|
||||
export function isValid(host: string): boolean {
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -221,6 +221,11 @@ export class Utils {
|
||||
if (httpUrl) {
|
||||
try {
|
||||
const url = Utils.getUrlObject(uriString);
|
||||
const validHostname = tldjs?.isValid != null ? tldjs.isValid(url.hostname) : true;
|
||||
if (!validHostname) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if (url.hostname === 'localhost' || Utils.validIpAddress(url.hostname)) {
|
||||
return url.hostname;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user