-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
total github downloads for all releases + all tags #535
Conversation
By the way the question from my original pull request remains: camp.route(/^\/github\/downloads\/([^\/]+)\/([^\/]+)\/([^\/]+)\/([^\/]+)\.(svg|png|gif|jpg|json)$/, The added (by me): camp.route(/^\/github\/downloads\/([^\/]+)\/([^\/]+)\.(svg|png|gif|jpg|json)$/, Will it work? |
any updates on this one? |
Sorry for the delay. In the case of conflicts, the first definition wins. However, I feel we can merge the two definitions into one. camp.route(/^\/github\/downloads\/([^\/]+)\/([^\/]+)\/([^\/]+)\/([^\/]+)\.(svg|png|gif|jpg|json)$/, That defines four slots: user, repo, the last two can either be:
Whether the last one is undefined determines whether we select by tag or over all tags. |
I updated the code to look for tag total. |
can you please check it? |
Any updates on this one? |
Sorry, every time I came back to it, I ended up taking a large amount of time trying to understand why it does not work. It turns out it was an unrelated issue with my setup. Having tag and asset_name be set to |
It has to do with the current pattern used in the current code base which expects specific amount of args. |
I think we can make the last parameter optional with this regex: |
Right, why I didn't think of it :) |
I have modified the code. |
There's a couple of things to fix, which I commented on https://github.com/sagiegurari/shields/commit/ec97d7a50694a776e25b223c34a5bfe0b9844ca1. |
Modified but not as you suggested exactly. as for the second comment about trailing slash, didn't see any issue in the url i'm building to fetch the info from the github rest api, so i'm not sure there is an issue (that part I did test, just not with cargo server). |
|
||
var apiUrl = 'https://api.github.com/repos/' + user + '/' + repo + '/releases'; | ||
if (!total) { | ||
var release_path = tag !== 'latest' ? 'tags/' + tag : 'latest'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I logged the values of tag and release_path, and tag was "/latest"
, and so release_path was "tags//latest"
(which still works, as most servers convert double slashes into single slashes), but not "latest"
, as the code presumably intends to do.
Either we must tag = tag.slice(1)
somewhere, or we must compare tag
to things that have a leading slash (ie, tag !== '/latest'
, and 'tags' + tag
).
added if (tag && (tag.indexOf('/') !== -1)) {
tag = tag.split('/').join('');
} |
|
||
if (tag && (tag.indexOf('/') !== -1)) { | ||
tag = tag.split('/').join(''); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why can't we replace that if (…) {…}
by a simple if (tag) { tag = tag.slice(1); }
?
I was almost tempted to merge and do that change myself, but I may be missing something.
I think the 'if' is safer to handle all scenarios. Might be wrong, but I think better to prevent the url issue and not by mistake mess up the tag. |
It is used for local testing, after all. Related to #535
Thanks! Given the regular expression, there cannot be more than one slash in |
Thanks 👍 |
when is this going to be deployed and available for use? |
Thanks for pinging me! It is deployed now. |
👍 thanks, it works good |
Recreated the original pull request (#526) based on comments and with latest badges repo to avoid conflict issues.