Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Trim line in LineInfo only once #24310

Merged
merged 1 commit into from
Jan 7, 2020
Merged
Show file tree
Hide file tree
Changes from all 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 @@ -68,13 +68,13 @@
*/
public class AppCacheManifestTransformer extends ResourceTransformerSupport {

private static final Collection<String> MANIFEST_SECTION_HEADERS =
Arrays.asList("CACHE MANIFEST", "NETWORK:", "FALLBACK:", "CACHE:");

private static final String MANIFEST_HEADER = "CACHE MANIFEST";

private static final String CACHE_HEADER = "CACHE:";

private static final Collection<String> MANIFEST_SECTION_HEADERS =
Arrays.asList(MANIFEST_HEADER, "NETWORK:", "FALLBACK:", CACHE_HEADER);

private static final Charset DEFAULT_CHARSET = StandardCharsets.UTF_8;

private static final Log logger = LogFactory.getLog(AppCacheManifestTransformer.class);
Expand Down Expand Up @@ -212,8 +212,9 @@ private static class LineInfo {


private static boolean initCacheSectionFlag(String line, @Nullable LineInfo previousLine) {
if (MANIFEST_SECTION_HEADERS.contains(line.trim())) {
return line.trim().equals(CACHE_HEADER);
String trimmedLine = line.trim();
if (MANIFEST_SECTION_HEADERS.contains(trimmedLine)) {
return trimmedLine.equals(CACHE_HEADER);
}
else if (previousLine != null) {
return previousLine.isCacheSection();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,13 +65,13 @@
*/
public class AppCacheManifestTransformer extends ResourceTransformerSupport {

private static final Collection<String> MANIFEST_SECTION_HEADERS =
Arrays.asList("CACHE MANIFEST", "NETWORK:", "FALLBACK:", "CACHE:");

private static final String MANIFEST_HEADER = "CACHE MANIFEST";

private static final String CACHE_HEADER = "CACHE:";

private static final Collection<String> MANIFEST_SECTION_HEADERS =
Arrays.asList(MANIFEST_HEADER, "NETWORK:", "FALLBACK:", CACHE_HEADER);

private static final Charset DEFAULT_CHARSET = StandardCharsets.UTF_8;

private static final Log logger = LogFactory.getLog(AppCacheManifestTransformer.class);
Expand Down Expand Up @@ -168,8 +168,9 @@ public LineInfo(String line, @Nullable LineInfo previous) {
}

private static boolean initCacheSectionFlag(String line, @Nullable LineInfo previousLine) {
if (MANIFEST_SECTION_HEADERS.contains(line.trim())) {
return line.trim().equals(CACHE_HEADER);
String trimmedLine = line.trim();
if (MANIFEST_SECTION_HEADERS.contains(trimmedLine)) {
return trimmedLine.equals(CACHE_HEADER);
}
else if (previousLine != null) {
return previousLine.isCacheSection();
Expand Down