@@ -52,6 +52,14 @@ export default function ContributorProfile() {
5252 setProfile ( null ) ;
5353 throw new Error ( "User not found" ) ;
5454 }
55+ if ( userRes . status === 403 ) {
56+ const rem = userRes . headers . get ( "x-ratelimit-remaining" ) ;
57+ const msg =
58+ rem === "0"
59+ ? "GitHub API rate limit exceeded. Please try again later."
60+ : "Access forbidden. If in development, set VITE_GITHUB_TOKEN." ;
61+ throw new Error ( msg ) ;
62+ }
5563 throw new Error ( `Failed to fetch user: ${ userRes . status } ` ) ;
5664 }
5765 const userData = await userRes . json ( ) ;
@@ -118,10 +126,13 @@ export default function ContributorProfile() {
118126
119127 if ( loading ) return < div className = "text-center mt-10" > Loading...</ div > ;
120128
121- if ( ! profile )
129+ if ( ! profile ) {
122130 return (
123- < div className = "text-center mt-10 text-red-600" > User not found.</ div >
131+ < div className = "text-center mt-10 text-red-600" >
132+ { errorMsg ?? "User not found." }
133+ </ div >
124134 ) ;
135+ }
125136
126137 return (
127138 < div className = "max-w-3xl mx-auto mt-2 mb-2 p-4 bg-white dark:bg-gray-800 dark:text-white shadow-xl rounded-xl" >
@@ -151,9 +162,16 @@ export default function ContributorProfile() {
151162 { prs . length > 0 ? (
152163 < ul className = "list-disc ml-6 space-y-2" >
153164 { prs . map ( ( pr ) => {
154- const repoName = pr . repository_url && pr . repository_url . includes ( "/" )
155- ? pr . repository_url . split ( "/" ) . slice ( - 2 ) . join ( "/" )
156- : "unknown" ;
165+ const repoName = ( ( ) => {
166+ if ( ! pr . repository_url ) return "unknown" ;
167+ try {
168+ const url = new URL ( pr . repository_url ) ;
169+ const parts = url . pathname . split ( "/" ) . filter ( Boolean ) ;
170+ return parts . slice ( - 2 ) . join ( "/" ) ;
171+ } catch {
172+ return "unknown" ;
173+ }
174+ } ) ( ) ;
157175 return (
158176 < li key = { pr . id } >
159177 < a
@@ -165,6 +183,8 @@ export default function ContributorProfile() {
165183 { `[${ repoName } ] ${ pr . title } ` }
166184 { pr . pull_request ?. merged_at ? (
167185 < span className = "ml-2 inline-block px-2 py-0.5 text-xs rounded bg-green-600/20 text-green-700 dark:text-green-300" > merged</ span >
186+ ) : pr . state === "closed" ? (
187+ < span className = "ml-2 inline-block px-2 py-0.5 text-xs rounded bg-gray-500/20 text-gray-700 dark:text-gray-300" > closed</ span >
168188 ) : null }
169189 </ a >
170190 </ li >
0 commit comments