1
0
mirror of https://github.com/bitwarden/jslib synced 2025-12-26 21:23:53 +00:00

Added testcases for punycode urls

This commit is contained in:
Daniel James Smith
2021-11-11 18:12:01 +01:00
parent 0eef358267
commit b777c1d525

View File

@@ -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');