github-url.ts
1 /** 2 * Build a base URL for linking to files on GitHub at a specific commit. 3 * Returns null when headSha is missing (e.g. loaded reviews without SHA). 4 */ 5 export function buildFileUrlBase(prUrl: string, headSha?: string): string | null { 6 if (!headSha) return null; 7 const match = prUrl.match(/^(https:\/\/github\.com\/[^/]+\/[^/]+)\//); 8 if (!match) return null; 9 return `${match[1]}/blob/${headSha}/`; 10 }