File size: 1,198 Bytes
4e23b01
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
import { describe, expect, it } from 'vitest';

import { normalizeRemote } from '../src/remote';

describe('normalizeRemote', () => {
  it.each([
    ['git@github.com:user/repo.git', 'github.com/user/repo'],
    ['https://github.com/user/repo.git', 'github.com/user/repo'],
    ['https://github.com/user/repo', 'github.com/user/repo'],
    ['http://github.com/user/repo.git', 'github.com/user/repo'],
    ['https://user:token@github.com/org/repo.git', 'github.com/org/repo'],
    ['http://user@github.com/org/repo.git', 'github.com/org/repo'],
    ['https://user:pass:word@github.com/repo.git', 'github.com/repo'],
    ['git@host.com:path/to/repo.git', 'host.com/path/to/repo'],
    ['git@host.com:path/to/repo', 'host.com/path/to/repo'],
    ['https://github.com/org/team/repo.git', 'github.com/org/team/repo'],
    ['github.com/user/repo', 'github.com/user/repo'],
    ['github.com/user/repo.git', 'github.com/user/repo'],
    ['user@host.com:path/repo.git', 'host.com/path/repo'],
    ['', ''],
    ['   ', ''],
    ['https://host.com:8443/path/repo.git', 'host.com/8443/path/repo'],
  ])('canonicalizes %s to %s', (url, expected) => {
    expect(normalizeRemote(url)).toBe(expected);
  });
});