File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1515package com .google .gitiles ;
1616
1717import com .google .common .base .Enums ;
18+ import com .google .common .base .Splitter ;
1819import com .google .common .base .Strings ;
1920import com .google .common .net .HttpHeaders ;
2021import java .util .Optional ;
@@ -29,6 +30,8 @@ public enum FormatType {
2930
3031 private static final String FORMAT_TYPE_ATTRIBUTE = FormatType .class .getName ();
3132
33+ private static final Splitter SPLITTER = Splitter .onPattern ("[ ,;][ ,;]*" );
34+
3235 public static Optional <FormatType > getFormatType (HttpServletRequest req ) {
3336 @ SuppressWarnings ("unchecked" )
3437 Optional <FormatType > result = (Optional <FormatType >) req .getAttribute (FORMAT_TYPE_ATTRIBUTE );
@@ -47,7 +50,7 @@ public static Optional<FormatType> getFormatType(HttpServletRequest req) {
4750 return set (req , Optional .of (DEFAULT ));
4851 }
4952
50- for (String p : accept .split ("[ ,;][ ,;]*" )) {
53+ for (String p : SPLITTER .split (accept )) {
5154 for (FormatType type : FormatType .values ()) {
5255 if (p .equals (type .mimeType )) {
5356 return set (req , Optional .of (type != HTML ? type : DEFAULT ));
You can’t perform that action at this time.
0 commit comments