提交 c3f1fc85 编写于 作者: C Christof Marti

Exclude port (#16680)

上级 8eb0cce4
......@@ -17,7 +17,7 @@ import { IOptions } from 'vs/workbench/common/options';
const SshProtocolMatcher = /^([^@:]+@)?([^:]+):/;
const SecondLevelDomainMatcher = /[^@.]+\.[^.]+$/;
const SecondLevelDomainMatcher = /([^@:.]+\.[^@:.]+)(:\d+)?$/;
const RemoteMatcher = /^\s*url\s*=\s*(.+\S)\s*$/mg;
type Tags = { [index: string]: boolean | number };
......@@ -142,7 +142,7 @@ export class WorkspaceStats {
private stripLowLevelDomains(domain: string): string {
let match = domain.match(SecondLevelDomainMatcher);
return match ? match[0] : null;
return match ? match[1] : null;
}
private extractDomain(url: string): string {
......
......@@ -14,8 +14,10 @@ suite('Telemetry - WorkspaceStats', () => {
const stats = new WorkspaceStats(null, null, null);
assert.deepStrictEqual(stats.getDomainsOfRemotes(remote('https://github.com/Microsoft/vscode.git')), ['github.com']);
assert.deepStrictEqual(stats.getDomainsOfRemotes(remote('https://git.example.com/gitproject.git')), ['example.com']);
assert.deepStrictEqual(stats.getDomainsOfRemotes(remote('https://username@github.com/username/repository.git')), ['github.com']);
assert.deepStrictEqual(stats.getDomainsOfRemotes(remote('https://username:password@github.com/username/repository.git')), ['github.com']);
assert.deepStrictEqual(stats.getDomainsOfRemotes(remote('https://username@github2.com/username/repository.git')), ['github2.com']);
assert.deepStrictEqual(stats.getDomainsOfRemotes(remote('https://username:password@github3.com/username/repository.git')), ['github3.com']);
assert.deepStrictEqual(stats.getDomainsOfRemotes(remote('https://username:password@example2.com:1234/username/repository.git')), ['example2.com']);
assert.deepStrictEqual(stats.getDomainsOfRemotes(remote('https://example3.com:1234/username/repository.git')), ['example3.com']);
});
test('SSH remotes', function () {
......@@ -27,7 +29,7 @@ suite('Telemetry - WorkspaceStats', () => {
const stats = new WorkspaceStats(null, null, null);
assert.deepStrictEqual(stats.getDomainsOfRemotes(remote('git@github.com:Microsoft/vscode.git')), ['github.com']);
assert.deepStrictEqual(stats.getDomainsOfRemotes(remote('user@git.server.org:project.git')), ['server.org']);
assert.deepStrictEqual(stats.getDomainsOfRemotes(remote('git.server.org:project.git')), ['server.org']);
assert.deepStrictEqual(stats.getDomainsOfRemotes(remote('git.server2.org:project.git')), ['server2.org']);
});
test('Local remotes', function () {
......@@ -36,6 +38,12 @@ suite('Telemetry - WorkspaceStats', () => {
assert.deepStrictEqual(stats.getDomainsOfRemotes(remote('file:///opt/git/project.git')), []);
});
test('Multiple remotes', function () {
const stats = new WorkspaceStats(null, null, null);
const config = ['https://github.com/Microsoft/vscode.git', 'https://git.example.com/gitproject.git'].map(remote).join('');
assert.deepStrictEqual(stats.getDomainsOfRemotes(config).sort(), ['example.com', 'github.com']);
});
function remote(url: string): string {
return `[remote "origin"]
url = ${url}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册