Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ class ResponseRedirector {
if (absolute) {
redirectURI = processedActualUri.contains('://') ? processedActualUri : serverBaseURL + processedActualUri
} else {
redirectURI = linkGenerator.contextPath + processedActualUri
redirectURI = processedActualUri
}

String redirectUrl = useJessionId ? response.encodeRedirectURL(redirectURI) : redirectURI
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,4 +114,26 @@ class RedirectNonAbsoluteURISpec extends AbstractUrlMappingsSpec {
cleanup:
RequestContextHolder.setRequestAttributes(null)
}

@Issue('15132')
void 'An "absolute=false" redirect not added context-path with url params'() {
given:
def linkGenerator = getLinkGeneratorWithContextPath {
"/$controller/$action?/$id?"()
}
def responseRedirector = new ResponseRedirector(linkGenerator)
HttpServletRequest request = Mock(HttpServletRequest) { lookup() >> GrailsWebMockUtil.bindMockWebRequest() }
HttpServletResponse response = Mock(HttpServletResponse)

when: 'redirecting with absolute=false where context-path is set'
String url = linkGenerator.link(controller:"test", action: "foo")
responseRedirector.redirect(request, response, [url:url, absolute: false])

then: 'the partial URL includes context-path'
1 * response.setHeader(HttpHeaders.LOCATION, "${CONTEXT_PATH}/test/foo")

cleanup:
RequestContextHolder.setRequestAttributes(null)
}

}
Loading