Auto-detecting branch from http Origin header


I’m using GitHub, and I’d like to be able to have a status badge that shows the status of a build for the branch I’m viewing. Right now I don’t think I can, because badge URLs must specify the branch, and GitHub doesn’t have a way to substitute the viewed branch into markdown text. TravisCI gets around this like so:

If that’s not viable, I’m curious if there’s a workaround I haven’t thought of.