Open makii42 opened 7 years ago
That's a really interesting proposition and I'd love to see a pull request for this! My only hesitation is the extra traffic, since the service currently really struggles when response time from the npm/github APIs slows. So, encouraging more traffic on top of this might be problematic right now. However don't let that stop you - this is a brilliant idea and I'd love to see it happen :rocket: 😍
Just a thought, we should check the github proxy passes on the Referer
header (I don't know why it wouldn't but worth a check before you start the work!)
So, the first pass is there, and instantaneously I found the first downside: This won't work in all contexts, e.g. on npmjs.com, as the Referer
in this case only contains the package name, and the parse logic is still as dumb as possible right now, requiring a github.com-style URL.
Depending on how much logic is supposed to be on the server side, a resolution of such specific referrers is not impossible, but cumbersome, as it will require additional lookups, either local (if e.g. the package.json
contents are present) or remote.
While adding some dependency badges to repos, I was wondering why there is the necessity to specify user/org and repo name in the URL, as ideally this information is already passed via the
Referer
header.It should be possible to expose a route for the badges as well the link to the package dependencies page by taking a look at the referrer. One would have to extracts the right portions, which according to badge.js are
and generate a redirect to either the appropriate existing image- or page-route. Thinking about it, there are probably some pros and cons to do that. This is my first pass:
pros:
cons:
That's all I can come up with for now.
What would need to be done:
Referer
out of the request and extractsorg
,repo
and optionalref
values. Possibly, with regards to issue #94 also the hostname to determine the hosting service.302 Found
redirect. Route names e.g. for svg/auto.svg
/auto-dev.svg
/auto-peer.svg
/auto-optional.svg
What do you think about this feature? Would a contribution implementing this be welcome?