@saithodev/semantic-release-gitea
Version:
Publish release notes to Gitea
12 lines (11 loc) • 414 B
JavaScript
module.exports = repositoryUrl => {
const [match, auth, host, path] = /^(?!.+:\/\/)(?:(?<auth>.*)@)?(?<host>.*?):(?<path>.*)$/.exec(repositoryUrl) || [];
try {
const [, owner, repo] = /^\/(?<owner>[^/]+)?\/?(?<repo>.+?)(?:\.git)?$/.exec(
new URL(match ? `ssh://${auth ? `${auth}@` : ''}${host}/${path}` : repositoryUrl).pathname
);
return {owner, repo};
} catch (_) {
return {};
}
};