github-tools / github

A higher-level wrapper around the Github API. Intended for the browser.
BSD 3-Clause "New" or "Revised" License
3.6k stars 755 forks source link

RegExp Fix for _requestAllPages #582

Closed tamer1an closed 5 years ago

tamer1an commented 5 years ago

Hi @j-rewerts

Remember we remove ampersand in this PR https://github.com/github-tools/github/pull/575/commits/86775a64496ae26bd8607492a0606c78ed1f0c7b#diff-5a59658a5ca4e1b25fde329807afc34fR264-R265

https://github.com/github-tools/github/blob/86775a64496ae26bd8607492a0606c78ed1f0c7b/lib/Requestable.js#L264-L264

Unfortunately regexp then mach other get parameter like &per_page

nextUrl =
"https://github.ldn.swissbank.com/api/v3/organizations/68/repos?direction=desc&type=all&sort=updated&per_page=100&page=2"
parseInt(nextUrl.match(/(page=[0-9]*)/g).shift().split('=').pop()); // 100

parseInt(nextUr.match(/([&\?]page=[0-9]*)/g).shift().split('=').pop()); // 2

@j-rewerts I suggest to add use this improved regexp that will match both cases: ?page=, &page=