all-contributors / cli

Tool to help automate adding contributor acknowledgements according to the all-contributors specification ✨
https://allcontributors.org
Other
414 stars 146 forks source link

fix: trim `nextLink` before slicing #309

Closed jtoar closed 2 years ago

jtoar commented 2 years ago

Hey all! I think I found and fixed a small bug; using this PR to start a discussion. When I tried updating Redwood's all contributors table, I got a Only absolute URLs are supported error, so I dug in a bit. This is the command I ran:

yarn all-contributors check --config .all-contributorsrc

And here's the .all-contributorsrc file: https://github.com/redwoodjs/redwood/blob/main/tasks/all-contributors/.all-contributorsrc.

I stepped through the code and narrowed it down; the error's happening in the getNextLink function. Here's the value for link:

'<https://api.github.com/repositories/191051391/contributors?per_page=100&page=1>; rel="prev", <https://api.github.com/repositories/191051391/contributors?per_page=100&page=3>; rel="next", <https://api.github.com/repositories/191051391/contributors?per_page=100&page=3>; rel="last", <https://api.github.com/repositories/191051391/contributors?per_page=100&page=1>; rel="first"'

The function splits link on commas and looks for rel=next. In this case, it's the second link. So splitting it results in:

// Note the space
' <https://api.github.com/repositories/191051391/contributors?per_page=100&page=3>; rel="next"'

That means the next call (return nextLink.split(';')[0].slice(1, -1);) results in:

// We got rid of the space, but < remains
'<https://api.github.com/repositories/191051391/contributors?per_page=100&page=3'

When another function tries to fetch this link, it throws.

It seems like all we need to do is trim the string before slicing, but let me know what you think!

jtoar commented 2 years ago

Hey @Berkmann18, I can't seem to access the logs of the failing check. Do I need permissions or is there another way I can see what's going on there?

Berkmann18 commented 2 years ago

@jtoar It 404'ed for me, so I re-ran the failing jobs.

all-contributors-release-bot commented 2 years ago

:tada: This PR is included in version 6.20.3 :tada:

The release is available on:

Your semantic-release bot :package::rocket: