blob: 33a29ecb2cb8daf567db40e628792527dfd2dd3a (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
|
import {sanitizeRepoName, substituteRepoOpenWithUrl} from './repo-common.ts';
test('substituteRepoOpenWithUrl', () => {
// For example: "x-github-client://openRepo/https://github.com/go-gitea/gitea"
expect(substituteRepoOpenWithUrl('proto://a/{url}', 'https://gitea')).toEqual('proto://a/https://gitea');
expect(substituteRepoOpenWithUrl('proto://a?link={url}', 'https://gitea')).toEqual('proto://a?link=https%3A%2F%2Fgitea');
});
test('sanitizeRepoName', () => {
expect(sanitizeRepoName(' a b ')).toEqual('a-b');
expect(sanitizeRepoName('a-b_c.git ')).toEqual('a-b_c');
expect(sanitizeRepoName('/x.git/')).toEqual('-x.git-');
expect(sanitizeRepoName('.profile')).toEqual('.profile');
expect(sanitizeRepoName('.profile.')).toEqual('.profile');
expect(sanitizeRepoName('.pro..file')).toEqual('.pro.file');
expect(sanitizeRepoName('foo.rss.atom.git.wiki')).toEqual('foo');
expect(sanitizeRepoName('.')).toEqual('');
expect(sanitizeRepoName('..')).toEqual('');
expect(sanitizeRepoName('-')).toEqual('');
});
|