jsx-readme
Version:
Generate Readme files with a React-like syntax and package.json-aware helpers.
23 lines • 991 B
JavaScript
;
/**
* @packageDocumentation
* @internal
*/
Object.defineProperty(exports, "__esModule", { value: true });
exports.extractGithubOwnerAndRepo = void 0;
const extractFirstMatch_1 = require("./extractFirstMatch");
function extractGithubOwnerAndRepo(repository) {
if (repository === undefined) {
return undefined;
}
const url = getUrlFromRepository(repository);
const SHORTFORM_REGEX = /^github:(?<owner>[-\w]+)\/(?<repo>[-\w]+)$/;
const SSH_REGEX = /^git@github\.com:(?<owner>[-\w]+)\/(?<repo>[-\w]+)\.git$/;
const HTTPS_REGEX = /^https:\/\/(?:www\.)?github\.com\/(?<owner>[-\w]+)\/(?<repo>[-\w]+)\.git$/;
return (0, extractFirstMatch_1.extractFirstMatch)(url, [SHORTFORM_REGEX, SSH_REGEX, HTTPS_REGEX]);
}
exports.extractGithubOwnerAndRepo = extractGithubOwnerAndRepo;
function getUrlFromRepository(repository) {
return typeof repository === "string" ? repository : repository.url;
}
//# sourceMappingURL=extractGithubOwnerAndRepo.js.map