actually extract .html.erb files

This commit is contained in:
erik-krogh
2023-02-14 23:25:44 +01:00
parent 4be2e431ea
commit f9b3a5b5e6

View File

@@ -104,7 +104,7 @@ public class FileExtractor {
/** Information about supported file types. */
public static enum FileType {
HTML(".htm", ".html", ".xhtm", ".xhtml", ".vue", ".hbs", ".ejs", ".njk", ".html.erb") {
HTML(".htm", ".html", ".xhtm", ".xhtml", ".vue", ".hbs", ".ejs", ".njk", ".erb") {
@Override
public IExtractor mkExtractor(ExtractorConfig config, ExtractorState state) {
return new HTMLExtractor(config, state);
@@ -120,6 +120,12 @@ public class FileExtractor {
if (isBinaryFile(f, lcExt, config)) {
return false;
}
// for ERB files we are only interrested in `.html.erb` files
if (FileUtil.extension(f).equalsIgnoreCase(".erb")) {
if (!f.getName().endsWith(".html.erb")) {
return false;
}
}
return super.contains(f, lcExt, config);
}
},
@@ -350,7 +356,7 @@ public class FileExtractor {
/** Determine the {@link FileType} for a given file based on its extension only. */
public static FileType forFileExtension(File f) {
String lcExt = StringUtil.lc(FileUtil.extension(f));
String lcExt = StringUtil.lc(FileUtil.extension(f)); // TODO: Here, it doesn't recognize .html.erb files
for (FileType tp : values())
if (tp.getExtensions().contains(lcExt)) {
return tp;