Turns out there was a bug in the original code. The intended behavior is that `this.base` is prepended whenever `uri` does not begin with `this.base` already (not merely contain it). So it really ought to test `uri.indexOf(this.base)` or `uri.indexOf(this.base) !== 0`.