Reconstructing the base URL from a request when
host_href is not set must take into account that
an URL path may consist of and endpoint part followed
by a resource path, e.g.:
'http://localhost/key-manager/v1/secrets/25a24d6b-605e-4226-ab39-7e2d8e10f559'
where the endpoint URL is `http://localhost/key-manager/v1`
The pecan.request.application_url is used instead of
pecan.request.url to retrieve the base URL part
(`http://localhost/key-manager/v1`) excluding the resource
path. However, the /v1 version particle is included into the
application_url value because it is implemented by a wsgi
application rather than a pecan controller, so the /v1 bit
also needs to be removed from the base URL when present.
Change-Id: I3c05f3d2f9a970213ca8347d7bbe1aac203af0a1
Closes-Bug: #1749217
(cherry picked from commit ff55d17034)