This pull has a bunch of manual string manipulation to check for, add, and remove the trailing 'edit' segment. It makes me nervous that the presence or absence of trailing slashes or query strings could through off these "dumb" string manipulations.

Consider helpers to ``utility`` like ``urlHasTrailingSegment(href, 'edit')`` and ``removeLastSegmentIfExists('edit')`` that are not sensitive to trailing slashes, and will work if there is a query string.