Files
actions-ansi-to-html/node_modules/@semantic-release/github/lib/parse-github-url.js
T
2025-11-11 06:53:11 -05:00

12 lines
412 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 {};
}
};