Set cookie path to context path without trailing slash

Closes gh-1863
This commit is contained in:
Eleftheria Stein
2021-07-20 10:00:53 +02:00
parent 8b5b3701da
commit 971a2d17d9
3 changed files with 9 additions and 8 deletions

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2014-2019 the original author or authors.
* Copyright 2014-2021 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -432,7 +432,8 @@ public class DefaultCookieSerializer implements CookieSerializer {
private String getCookiePath(HttpServletRequest request) {
if (this.cookiePath == null) {
return request.getContextPath() + "/";
String contextPath = request.getContextPath();
return (contextPath != null && contextPath.length() > 0) ? contextPath : "/";
}
return this.cookiePath;
}