Uploaded image for project: 'JBoss Enterprise Application Platform'
  1. JBoss Enterprise Application Platform
  2. JBEAP-4698

UriInfo#getPath() is missing trailing slash

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Done
    • Icon: Major Major
    • 7.0.1.CR1, 7.0.1.GA
    • None
    • REST
    • None
    • Hide

      You can use

      "/" + uriInfo.getBaseUri().relativize(uriInfo.getAbsolutePath()).toString()
      

      or for simpler cases where you only need to check that the path ends with a slash, use

      uriInfo.getAbsolutePath().getPath().endsWith("/")
      

      or

      uriInfo.getRequestUri().getPath().endsWith("/")
      
      Show
      You can use "/" + uriInfo.getBaseUri().relativize(uriInfo.getAbsolutePath()).toString() or for simpler cases where you only need to check that the path ends with a slash, use uriInfo.getAbsolutePath().getPath().endsWith( "/" ) or uriInfo.getRequestUri().getPath().endsWith( "/" )
    • EAP 7.0.1

      This is a follow-up to RESTEASY-1077.

      getPath() and getPath(false) are missing the trailing slash, when getAbsolutePath() correctly contains it.

      This contradicts the javadoc for getAbsolutePath() saying that it's equivalent to uriInfo.getBaseUri().resolve(uriInfo.getPath(false)).

      This breaks code such as:

            if (!uriInfo.getPath().endsWith("/")) {
              // make sure there's a trailing slash (for correct relative URI resolution)
              return Response
                  .status(Response.Status.MOVED_PERMANENTLY)
                  .location(uriInfo.getBaseUriBuilder().path("/test/").build())
                  .build();
            }
            …
      

              rsigal@redhat.com Ronald Sigal
              t.broyer Thomas Broyer (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

                Created:
                Updated:
                Resolved: