UNPKG

@featurevisor/core

Version:

Core package of Featurevisor for Node.js usage

18 lines (15 loc) 496 B
export function getOwnerAndRepoFromUrl(url: string): { owner: string; repo: string } { let owner; let repo; if (url.startsWith("https://")) { const parts = url.split("/"); repo = (parts.pop() as string).replace(".git", ""); owner = parts.pop(); } else if (url.startsWith("git@")) { const urlParts = url.split(":"); const parts = urlParts[1].split("/"); repo = (parts.pop() as string).replace(".git", ""); owner = parts.pop(); } return { owner, repo }; }