File tree Expand file tree Collapse file tree 3 files changed +9
-6
lines changed Expand file tree Collapse file tree 3 files changed +9
-6
lines changed Original file line number Diff line number Diff line change @@ -5,6 +5,7 @@ node_modules/
5
5
composer.phar
6
6
yarn.lock
7
7
package-lock.json
8
+ .vercel
8
9
9
10
# Local Configuration
10
11
package.json
Original file line number Diff line number Diff line change 32
32
33
33
try {
34
34
// get streak stats for user given in query string
35
- $ contributionGraphs = getContributionGraphs ($ _REQUEST ["user " ]);
35
+ $ user = preg_replace ("/[^a-zA-Z0-9\-]/ " , "" , $ _REQUEST ["user " ]);
36
+ $ contributionGraphs = getContributionGraphs ($ user );
36
37
$ contributions = getContributionDates ($ contributionGraphs );
37
38
if (isset ($ _GET ["mode " ]) && $ _GET ["mode " ] === "weekly " ) {
38
39
$ stats = getWeeklyContributionStats ($ contributions );
Original file line number Diff line number Diff line change @@ -191,13 +191,14 @@ function getContributionYears(string $user): array
191
191
} " ;
192
192
$ response = fetchGraphQL ($ query );
193
193
// User not found
194
- if (!empty ($ response ->errors ) && $ response ->errors [0 ]->type === "NOT_FOUND " ) {
195
- throw new InvalidArgumentException ("Could not find a user with that name. " , 404 );
196
- }
197
- // API Error
198
194
if (!empty ($ response ->errors )) {
195
+ $ type = $ response ->errors [0 ]->type ?? "" ;
196
+ if ($ type === "NOT_FOUND " ) {
197
+ throw new InvalidArgumentException ("Could not find a user with that name. " , 404 );
198
+ }
199
+ $ message = $ response ->errors [0 ]->message ?? "An API error occurred. " ;
199
200
// Other errors that contain a message field
200
- throw new InvalidArgumentException ($ response -> errors [ 0 ]-> message , 500 );
201
+ throw new InvalidArgumentException ($ message , 500 );
201
202
}
202
203
// API did not return data
203
204
if (!isset ($ response ->data ) && isset ($ response ->message )) {
You can’t perform that action at this time.
0 commit comments