[PR #1948] fix: more permissive owner/repo detection #10126

Closed
opened 2026-02-16 18:14:44 -05:00 by yindo · 0 comments
Owner

Original Pull Request: https://github.com/anomalyco/opencode/pull/1948

State: closed
Merged: Yes


fixes: #1361

just to show it works:

const patterns = [
  "https://github.com/sst/opencode.git",
  "https://github.com/sst/opencode",
  "git@github.com:sst/opencode.git",
  "git@github.com:sst/opencode",
  "ssh://git@github.com/sst/opencode.git",
  "ssh://git@github.com/sst/opencode",
]

patterns.forEach((pattern) => {
  const parsed = pattern.match(/^(?:(?:https?|ssh):\/\/)?(?:git@)?github\.com[:/]([^/]+)\/([^/.]+?)(?:\.git)?$/)
  if (!parsed) {
    console.error(`Invalid pattern: ${pattern}`)
  } else {
    const [, owner, repo] = parsed
    console.log(`pattern: ${pattern}\n  Owner: ${owner}, Repo: ${repo}\n`)
  }
})

$ bun run script.local.ts
pattern: https://github.com/sst/opencode.git
  Owner: sst, Repo: opencode

pattern: https://github.com/sst/opencode
  Owner: sst, Repo: opencode

pattern: git@github.com:sst/opencode.git
  Owner: sst, Repo: opencode

pattern: git@github.com:sst/opencode
  Owner: sst, Repo: opencode

pattern: ssh://git@github.com/sst/opencode.git
  Owner: sst, Repo: opencode

pattern: ssh://git@github.com/sst/opencode
  Owner: sst, Repo: opencode
**Original Pull Request:** https://github.com/anomalyco/opencode/pull/1948 **State:** closed **Merged:** Yes --- fixes: #1361 just to show it works: ```ts const patterns = [ "https://github.com/sst/opencode.git", "https://github.com/sst/opencode", "git@github.com:sst/opencode.git", "git@github.com:sst/opencode", "ssh://git@github.com/sst/opencode.git", "ssh://git@github.com/sst/opencode", ] patterns.forEach((pattern) => { const parsed = pattern.match(/^(?:(?:https?|ssh):\/\/)?(?:git@)?github\.com[:/]([^/]+)\/([^/.]+?)(?:\.git)?$/) if (!parsed) { console.error(`Invalid pattern: ${pattern}`) } else { const [, owner, repo] = parsed console.log(`pattern: ${pattern}\n Owner: ${owner}, Repo: ${repo}\n`) } }) ``` ```zsh $ bun run script.local.ts pattern: https://github.com/sst/opencode.git Owner: sst, Repo: opencode pattern: https://github.com/sst/opencode Owner: sst, Repo: opencode pattern: git@github.com:sst/opencode.git Owner: sst, Repo: opencode pattern: git@github.com:sst/opencode Owner: sst, Repo: opencode pattern: ssh://git@github.com/sst/opencode.git Owner: sst, Repo: opencode pattern: ssh://git@github.com/sst/opencode Owner: sst, Repo: opencode ```
yindo added the pull-request label 2026-02-16 18:14:44 -05:00
yindo closed this issue 2026-02-16 18:14:44 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: anomalyco/opencode#10126