[keycloak-dev] Trailing slash
sthorger at redhat.com
Wed Feb 20 09:34:27 EST 2019
That being said I have no clue why it was added and if it would break
something to fix it ;)
On Wed, 20 Feb 2019 at 15:34, Stian Thorgersen <sthorger at redhat.com> wrote:
> That is some strange behaviour and I agree "/path/" is not the same as
> "/path" so this is an invalid rewrite of the URL.
> On Wed, 20 Feb 2019 at 14:50, Sebastian Laskawiec <slaskawi at redhat.com>
>> Hey guys,
>> I'm working on migrating Jetty adapters to our base testsuite at the
>> and I noticed an interesting problem.
>> The URLProvider is responsible for adjusting injected URLs into the Page
>> objects. One of the things it does is trimming the trailing slash out, so
>> that "http://localhost:8280/client-secret-jwt-secure-portal/" becomes "
>> http://localhost:8280/client-secret-jwt-secure-portal". We depend on this
>> functionality a lot in our testsuite when constructing all kind of
>> assertions that include myPage.getInjectedUrl().toString(). In other
>> if we inject a URL with a trailing slash, there will be quite a lot of
>> that fail.
>> Trailing space at the end is not meaningless unfortunately. It is being
>> used by the container to find proper context. Here's one of the best
>> explanations I found so far .
>> Jetty enforces trailing slashes for Servlets deployed in the container. If
>> you hit a Servlet without a slash (
>> http://localhost:8280/client-secret-jwt-secure-portal for example), you
>> will be redirected (with HTTP 302) to a version that has it (
>> http://localhost:8280/client-secret-jwt-secure-portal/). This of course
>> breaks some of the tests in our testsuite (since the Resteasy HTTP Engine
>> doesn't follow redirects by default). It is also worth to mention, that
>> Arquillian also adds trailing slash at the end of the Servlet context .
>> So by default, it injects all URLs with trailing space.
>> My take on this is that we should not trim the trailing slash. Moreover,
>> should never manipulate a raw string representation of a URL. What we
>> should do instead is to use URI#resolve method if we need to query
>> sub-contexts. Using URI instead of URL is extremely important when it
>> to equality (if you're interested more in this, please read ).
>> If you agree with me, I'll go ahead and create a JIRA for it.
>>  http://blog.markfeeney.com/2010/11/java-uri-vs-url.html
>> keycloak-dev mailing list
>> keycloak-dev at lists.jboss.org
More information about the keycloak-dev