123
124
/** Extracts the host of a marketplace reference for `hostPattern` matching. */
126
>
if (ref.kind === MarketplaceReferenceKind.GitHubShorthand) {
127
>
return 'github.com';
128
>
}
129
>
if (ref.kind !== MarketplaceReferenceKind.GitUri) {
130
return undefined;
131
}
133
>
const scpMatch = /^[\w._-]+@([\w.-]+):/.exec(ref.cloneUrl);
134
>
if (scpMatch) {
135
return scpMatch[1].toLowerCase();
136
}
138
>
let authority = URI.parse(ref.cloneUrl).authority.toLowerCase();
139
>
const at = authority.lastIndexOf('@');
140
>
if (at !== -1) {
141
authority = authority.slice(at + 1);
142
}
144
>
if (colon !== -1) {
145
authority = authority.slice(0, colon);
146
}
148
>
} catch {
149
return undefined;
150
}
152
153
/** Tests a regex pattern against a value, treating invalid patterns as non-matching. */