projects
/
jSite.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
2d6256e
)
Ignore charsets when checking for HTML index file
author
David ‘Bombe’ Roden
<bombe@freenetproject.org>
Sun, 18 Sep 2016 17:49:40 +0000
(19:49 +0200)
committer
David ‘Bombe’ Roden
<bombe@freenetproject.org>
Sun, 18 Sep 2016 17:49:40 +0000
(19:49 +0200)
src/main/java/de/todesbaum/jsite/application/validation/ProjectValidator.java
patch
|
blob
|
history
src/test/java/de/todesbaum/jsite/application/validation/ProjectValidatorTest.java
patch
|
blob
|
history
diff --git
a/src/main/java/de/todesbaum/jsite/application/validation/ProjectValidator.java
b/src/main/java/de/todesbaum/jsite/application/validation/ProjectValidator.java
index
2e03e6c
..
a25aa9d
100644
(file)
--- a/
src/main/java/de/todesbaum/jsite/application/validation/ProjectValidator.java
+++ b/
src/main/java/de/todesbaum/jsite/application/validation/ProjectValidator.java
@@
-10,6
+10,7
@@
import java.util.Set;
import java.util.concurrent.CountDownLatch;
import java.util.logging.Level;
import java.util.logging.Logger;
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;
import de.todesbaum.jsite.application.FileOption;
import de.todesbaum.jsite.application.Project;
@@
-44,8
+45,7
@@
public class ProjectValidator {
}
String indexFile = project.getIndexFile();
boolean hasIndexFile = (indexFile != null) && (indexFile.length() > 0);
}
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();
checkReport.addIssue("warning.index-not-html", false);
}
Map<String, FileOption> fileOptions = project.getFileOptions();
@@
-104,4
+104,9
@@
public class ProjectValidator {
return checkReport;
}
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));
+ }
+
}
}
diff --git
a/src/test/java/de/todesbaum/jsite/application/validation/ProjectValidatorTest.java
b/src/test/java/de/todesbaum/jsite/application/validation/ProjectValidatorTest.java
index
545ab45
..
b2c3c9c
100644
(file)
--- a/
src/test/java/de/todesbaum/jsite/application/validation/ProjectValidatorTest.java
+++ b/
src/test/java/de/todesbaum/jsite/application/validation/ProjectValidatorTest.java
@@
-99,6
+99,13
@@
public class ProjectValidatorTest {
}
@Test
}
@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);
public void notInsertingTheIndexFileAnyFileResultsInError() {
project.getFileOption("index.html").setInsert(false);
project.getFileOption("index.html").setInsertRedirect(false);