Skip to content

Commit

Permalink
SameSite is capital first letter only.
Browse files Browse the repository at this point in the history
Signed-off-by: jansupol <[email protected]>
  • Loading branch information
jansupol committed Nov 21, 2023
1 parent 17c4a2c commit 0977d17
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2010, 2021 Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2010, 2023 Oracle and/or its affiliates. All rights reserved.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v. 2.0, which is available at
Expand All @@ -23,6 +23,8 @@
import org.glassfish.jersey.internal.LocalizationMessages;
import org.glassfish.jersey.spi.HeaderDelegateProvider;

import java.util.Locale;

import static org.glassfish.jersey.message.internal.Utils.throwIllegalArgumentExceptionIfNull;

/**
Expand Down Expand Up @@ -75,7 +77,7 @@ public String toString(final NewCookie cookie) {
}
if (cookie.getSameSite() != null) {
b.append(";SameSite=");
b.append(cookie.getSameSite());
b.append(getSameSite(cookie));
}
if (cookie.getExpiry() != null) {
b.append(";Expires=");
Expand All @@ -90,4 +92,9 @@ public NewCookie fromString(final String header) {
throwIllegalArgumentExceptionIfNull(header, LocalizationMessages.NEW_COOKIE_IS_NULL());
return HttpHeaderReader.readNewCookie(header);
}

private static String getSameSite(NewCookie cookie) {
final String siteName = cookie.getSameSite().name();
return siteName.charAt(0) + siteName.substring(1).toLowerCase(Locale.ROOT);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public class NewCookieProviderTest {
public void SameSiteTest() {
final NewCookieProvider provider = new NewCookieProvider();
final String newCookieString = provider.toString(newCookie);
assertTrue(newCookieString.contains("SameSite=STRICT"));
assertTrue(newCookieString.contains("SameSite=Strict"));
assertEquals(NewCookie.SameSite.STRICT, provider.fromString(newCookieString).getSameSite());
}

Expand Down

0 comments on commit 0977d17

Please sign in to comment.