diff --git a/spec/common/misc/utils.spec.ts b/spec/common/misc/utils.spec.ts index d5b79093..1122cc43 100644 --- a/spec/common/misc/utils.spec.ts +++ b/spec/common/misc/utils.spec.ts @@ -48,6 +48,12 @@ describe('Utils Service', () => { expect(Utils.getDomain('https://bitwarden.unknown')).toBe('bitwarden.unknown'); }); + it('should handle valid urls with an underscore in subdomain', () => { + expect(Utils.getDomain('my_vault.bitwarden.com/')).toBe('bitwarden.com'); + expect(Utils.getDomain('http://my_vault.bitwarden.com/')).toBe('bitwarden.com'); + expect(Utils.getDomain('https://my_vault.bitwarden.com/')).toBe('bitwarden.com'); + }); + it('should support localhost', () => { expect(Utils.getDomain('localhost')).toBe('localhost'); expect(Utils.getDomain('http://localhost')).toBe('localhost'); @@ -110,6 +116,10 @@ describe('Utils Service', () => { expect(Utils.getHostname('https://bitwarden.unknown')).toBe('bitwarden.unknown'); }); + it('should handle valid urls with an underscore in subdomain', () => { + expect(Utils.getHostname('my_vault.bitwarden.com/')).toBe('my_vault.bitwarden.com'); + expect(Utils.getHostname('http://my_vault.bitwarden.com/')).toBe('my_vault.bitwarden.com'); + expect(Utils.getHostname('https://my_vault.bitwarden.com/')).toBe('my_vault.bitwarden.com'); }); it('should support localhost', () => {