1
0
mirror of https://github.com/bitwarden/jslib synced 2025-12-20 18:23:52 +00:00

Added tests to verify handling of localhost with subdomain

This commit is contained in:
Daniel James Smith
2021-11-11 17:03:32 +01:00
parent a9bc646c4a
commit cf302d780c

View File

@@ -58,7 +58,12 @@ describe('Utils Service', () => {
expect(Utils.getDomain('localhost')).toBe('localhost'); expect(Utils.getDomain('localhost')).toBe('localhost');
expect(Utils.getDomain('http://localhost')).toBe('localhost'); expect(Utils.getDomain('http://localhost')).toBe('localhost');
expect(Utils.getDomain('https://localhost')).toBe('localhost'); expect(Utils.getDomain('https://localhost')).toBe('localhost');
});
it('should support localhost with subdomain', () => {
expect(Utils.getDomain('subdomain.localhost')).toBe('localhost');
expect(Utils.getDomain('http://subdomain.localhost')).toBe('localhost');
expect(Utils.getDomain('https://subdomain.localhost')).toBe('localhost');
}); });
it('should support IPv4', () => { it('should support IPv4', () => {
@@ -127,6 +132,12 @@ describe('Utils Service', () => {
expect(Utils.getHostname('https://localhost')).toBe('localhost'); expect(Utils.getHostname('https://localhost')).toBe('localhost');
}); });
it('should support localhost with subdomain', () => {
expect(Utils.getHostname('subdomain.localhost')).toBe('subdomain.localhost');
expect(Utils.getHostname('http://subdomain.localhost')).toBe('subdomain.localhost');
expect(Utils.getHostname('https://subdomain.localhost')).toBe('subdomain.localhost');
});
it('should support IPv4', () => { it('should support IPv4', () => {
expect(Utils.getHostname('192.168.1.1')).toBe('192.168.1.1'); expect(Utils.getHostname('192.168.1.1')).toBe('192.168.1.1');
expect(Utils.getHostname('http://192.168.1.1')).toBe('192.168.1.1'); expect(Utils.getHostname('http://192.168.1.1')).toBe('192.168.1.1');