mirror of
https://github.com/bitwarden/jslib
synced 2025-12-12 14:23:20 +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:
@@ -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