parent
6ddacdc01d
commit
e60e8dc582
|
@ -374,7 +374,7 @@ public abstract class AbstractSockJsService implements SockJsService {
|
|||
// Try SockJS prefix hints
|
||||
if (!this.validSockJsPrefixes.isEmpty()) {
|
||||
for (String prefix : this.validSockJsPrefixes) {
|
||||
int index = path.indexOf(prefix);
|
||||
int index = path.lastIndexOf(prefix);
|
||||
if (index != -1) {
|
||||
this.knownSockJsPrefixes.add(path.substring(0, index + prefix.length()));
|
||||
return path.substring(index + prefix.length());
|
||||
|
|
|
@ -113,6 +113,17 @@ public class AbstractSockJsServiceTests extends AbstractHttpRequestTests {
|
|||
assertSame(this.handler, this.service.handler);
|
||||
}
|
||||
|
||||
// SPR-10923
|
||||
|
||||
@Test
|
||||
public void getSockJsPathWithPartlyMatchingServletPath() throws Exception {
|
||||
|
||||
this.service.setValidSockJsPrefixes("/snake");
|
||||
handleRequest("GET", "/snakedemo/snake/info", HttpStatus.OK);
|
||||
|
||||
assertTrue(this.servletResponse.getContentAsString().startsWith("{\"entropy\":"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void validateRequest() throws Exception {
|
||||
|
||||
|
@ -146,7 +157,7 @@ public class AbstractSockJsServiceTests extends AbstractHttpRequestTests {
|
|||
|
||||
String body = this.servletResponse.getContentAsString();
|
||||
assertEquals("{\"entropy\"", body.substring(0, body.indexOf(':')));
|
||||
assertEquals(",\"origins\":[\"*:*\"],\"cookie_needed\":false,\"websocket\":true}",
|
||||
assertEquals(",\"origins\":[\"*:*\"],\"cookie_needed\":true,\"websocket\":true}",
|
||||
body.substring(body.indexOf(',')));
|
||||
|
||||
this.service.setSessionCookieNeeded(false);
|
||||
|
|
Loading…
Reference in New Issue