From b777c1d525ea5fff775713f723e6e9046b081543 Mon Sep 17 00:00:00 2001 From: Daniel James Smith Date: Thu, 11 Nov 2021 18:12:01 +0100 Subject: [PATCH] Added testcases for punycode urls --- spec/common/misc/utils.spec.ts | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/spec/common/misc/utils.spec.ts b/spec/common/misc/utils.spec.ts index a3bed402..0d163706 100644 --- a/spec/common/misc/utils.spec.ts +++ b/spec/common/misc/utils.spec.ts @@ -64,6 +64,16 @@ describe('Utils Service', () => { expect(Utils.getDomain('https://subdomain.bütwarden.com')).toBe('bütwarden.com'); }); + it('should support punycode urls', () => { + expect(Utils.getDomain('xn--btwarden-65a.com')).toBe('xn--btwarden-65a.com'); + expect(Utils.getDomain('xn--btwarden-65a.com')).toBe('xn--btwarden-65a.com'); + expect(Utils.getDomain('xn--btwarden-65a.com')).toBe('xn--btwarden-65a.com'); + + expect(Utils.getDomain('subdomain.xn--btwarden-65a.com')).toBe('xn--btwarden-65a.com'); + expect(Utils.getDomain('http://subdomain.xn--btwarden-65a.com')).toBe('xn--btwarden-65a.com'); + expect(Utils.getDomain('https://subdomain.xn--btwarden-65a.com')).toBe('xn--btwarden-65a.com'); + }); + it('should support localhost', () => { expect(Utils.getDomain('localhost')).toBe('localhost'); expect(Utils.getDomain('http://localhost')).toBe('localhost'); @@ -146,6 +156,16 @@ describe('Utils Service', () => { expect(Utils.getHostname('https://subdomain.bütwarden.com')).toBe('subdomain.bütwarden.com'); }); + it('should support punycode urls', () => { + expect(Utils.getHostname('xn--btwarden-65a.com')).toBe('xn--btwarden-65a.com'); + expect(Utils.getHostname('xn--btwarden-65a.com')).toBe('xn--btwarden-65a.com'); + expect(Utils.getHostname('xn--btwarden-65a.com')).toBe('xn--btwarden-65a.com'); + + expect(Utils.getHostname('subdomain.xn--btwarden-65a.com')).toBe('subdomain.xn--btwarden-65a.com'); + expect(Utils.getHostname('http://subdomain.xn--btwarden-65a.com')).toBe('subdomain.xn--btwarden-65a.com'); + expect(Utils.getHostname('https://subdomain.xn--btwarden-65a.com')).toBe('subdomain.xn--btwarden-65a.com'); + }); + it('should support localhost', () => { expect(Utils.getHostname('localhost')).toBe('localhost'); expect(Utils.getHostname('http://localhost')).toBe('localhost');