From 96f925ac07f1c71af4b97ef541e82b7a3fb9049a Mon Sep 17 00:00:00 2001 From: Daniel James Smith Date: Thu, 11 Nov 2021 16:42:32 +0100 Subject: [PATCH] Add tests for url with an underscore in the subdomain --- spec/common/misc/utils.spec.ts | 10 ++++++++++ 1 file changed, 10 insertions(+) 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', () => {