I did this, and pulled the logic into a method (see below), for testability.  Making `endpoint_re` public didn't seem to be an issue.