Git with a cup of tea, painless self-hosted git service
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

22 lines
1.0 KiB

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('');
});