File size: 581 Bytes
7c5ed63
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
import { describe, it, expect } from 'vitest';
import { hostForUrl } from '../../src/config';

describe('hostForUrl', () => {
  it('brackets a bare IPv6 literal for use in a URL', () => {
    expect(hostForUrl('::1')).toBe('[::1]');
  });

  it('leaves an IPv4 literal unchanged', () => {
    expect(hostForUrl('127.0.0.1')).toBe('127.0.0.1');
  });

  it('leaves a hostname unchanged', () => {
    expect(hostForUrl('localhost')).toBe('localhost');
  });

  it('leaves an already-bracketed IPv6 literal unchanged', () => {
    expect(hostForUrl('[::1]')).toBe('[::1]');
  });
});