UNPKG

781 BJavaScriptView Raw
1"use strict";
2Object.defineProperty(exports, "__esModule", { value: true });
3exports.getGitHubRepoSlug = void 0;
4function getGitHubRepoSlug(pkg) {
5 let match = null;
6 if (typeof pkg.repository === 'string') {
7 match = pkg.repository.match(/^(?:github:)?([^/:]+\/[^/:]+)$/);
8 }
9 else {
10 let url = null;
11 if (pkg.repository && typeof pkg.repository.url === 'string') {
12 url = pkg.repository && pkg.repository.url;
13 }
14 else if (typeof pkg.homepage === 'string') {
15 url = pkg.homepage;
16 }
17 else {
18 return null;
19 }
20 match = url.match(/github\.com\/([^/:]+\/[^/:]+?)(?:\.git|\/)?$/);
21 }
22 return (match && match[1]) || null;
23}
24exports.getGitHubRepoSlug = getGitHubRepoSlug;