import java.util.concurrent.CountDownLatch;
import java.util.logging.Level;
import java.util.logging.Logger;
+import java.util.stream.Stream;
import de.todesbaum.jsite.application.FileOption;
import de.todesbaum.jsite.application.Project;
}
String indexFile = project.getIndexFile();
boolean hasIndexFile = (indexFile != null) && (indexFile.length() > 0);
- List<String> allowedIndexContentTypes = Arrays.asList("text/html", "application/xhtml+xml");
- if (hasIndexFile && !allowedIndexContentTypes.contains(project.getFileOption(indexFile).getMimeType())) {
+ if (hasIndexFile && indexFileIsNotHtml(project, indexFile)) {
checkReport.addIssue("warning.index-not-html", false);
}
Map<String, FileOption> fileOptions = project.getFileOptions();
return checkReport;
}
+ private static boolean indexFileIsNotHtml(Project project, String indexFile) {
+ return Stream.of("text/html", "application/xhtml+xml")
+ .noneMatch(mimeType -> project.getFileOption(indexFile).getMimeType().startsWith(mimeType));
+ }
+
}
}
@Test
+ public void usingHtmlMimeTypeWithCharsetForIndexFileDoesNotResultInWarning() {
+ project.getFileOption("index.html").setMimeType("text/html; charset=UTF-8");
+ CheckReport checkReport = validateProject(project);
+ assertThat(checkReport.getIssues(), not(hasItem(new Issue("warning.index-not-html", false))));
+ }
+
+ @Test
public void notInsertingTheIndexFileAnyFileResultsInError() {
project.getFileOption("index.html").setInsert(false);
project.getFileOption("index.html").setInsertRedirect(false);