Skip to content

Function: repositoryUrl()

repositoryUrl(cwd?, format?): string | undefined

The repo’s canonical remote URL, or undefined when there is no git remote. Normalizes git remote get-url origin locally first, including SSH aliases, and only asks gh repo view when the remote cannot be parsed. This keeps authenticated GitHub account discovery lazy for callers that actually need it. A blank, omitted, or explicitly current cwd reuses cached command probes; another resolved directory executes directly.

string

directory to resolve from (defaults to process.cwd()).

"https" | "npm"

"https" (default) yields https://host/owner/repo; "npm" yields npm’s git+https://host/owner/repo.git form (for a package.json repository.url that passes npm provenance).

string | undefined