Conversation
✅ Deploy Preview for piech-dev ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
There was a problem hiding this comment.
Pull Request Overview
This PR refactors the GitHub data fetching logic to support both 'master' and 'main' branch naming conventions when retrieving package.json license information. The changes improve code readability and maintainability by restructuring conditional logic and adding fallback branch support.
Key changes:
- Added fallback logic to check both 'master' and 'main' branches when fetching package.json
- Refactored nested type checking for license object to improve code clarity
- Updated comments to reflect the new multi-branch fallback behavior
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
| for (const branch of candidateBranches) { | ||
| try { | ||
| const pkg = JSON.parse(raw) as unknown; | ||
| if ( | ||
| pkg && | ||
| typeof pkg === 'object' && | ||
| 'license' in (pkg as Record<string, unknown>) | ||
| ) { | ||
| const lic = (pkg as Record<string, unknown>).license; | ||
| if (typeof lic === 'string') return lic; | ||
| const raw = await fetchText( | ||
| `https://raw.githubusercontent.com/${owner}/${repo}/${branch}/package.json`, | ||
| ); |
There was a problem hiding this comment.
The loop will continue attempting to fetch from 'main' even after successfully retrieving and parsing a license from 'master'. Consider adding an early return after successfully finding a valid license to avoid unnecessary network requests.

No description provided.