Hacker News new | ask | show | jobs
by btown 4333 days ago
> Note that the snippet is repo-agnostic: It can be copy-pasted without modification and will work correctly if forked to a different repo. Heroku resolves the repo originating a button click by inspecting the referer header.

Is the referer reliable enough on modern browsers to assume this? Perhaps coming from an analytics perspective, we see all types of query-string hacks so that you can attribute the sources of links everywhere... so it's surprising to see a company depend on this functionality in a product. I suppose almost all developers would be using a browser that correctly sends referer headers... is this the case?

1 comments

They do mention an alternative where you can set stuff in the query string. I'd probably rather do that instead. Especially since you could easily end up putting that button out of the context of your repo at some point and have it end up completely broken.
But if I fork a repo with a button (or even navigate to different branch/commit in same repo), a manually set query string would still point to the same code. Whereas the referer headear can identify exactly the right version briliantly.