Skip to content

Commit f9b3a5b

Browse files
committed
actually extract .html.erb files
1 parent 4be2e43 commit f9b3a5b

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

javascript/extractor/src/com/semmle/js/extractor/FileExtractor.java

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ private static int skipBOM(byte[] bytes, int length) {
104104

105105
/** Information about supported file types. */
106106
public static enum FileType {
107-
HTML(".htm", ".html", ".xhtm", ".xhtml", ".vue", ".hbs", ".ejs", ".njk", ".html.erb") {
107+
HTML(".htm", ".html", ".xhtm", ".xhtml", ".vue", ".hbs", ".ejs", ".njk", ".erb") {
108108
@Override
109109
public IExtractor mkExtractor(ExtractorConfig config, ExtractorState state) {
110110
return new HTMLExtractor(config, state);
@@ -120,6 +120,12 @@ protected boolean contains(File f, String lcExt, ExtractorConfig config) {
120120
if (isBinaryFile(f, lcExt, config)) {
121121
return false;
122122
}
123+
// for ERB files we are only interrested in `.html.erb` files
124+
if (FileUtil.extension(f).equalsIgnoreCase(".erb")) {
125+
if (!f.getName().endsWith(".html.erb")) {
126+
return false;
127+
}
128+
}
123129
return super.contains(f, lcExt, config);
124130
}
125131
},
@@ -350,7 +356,7 @@ public static FileType forFile(File f, ExtractorConfig config) {
350356

351357
/** Determine the {@link FileType} for a given file based on its extension only. */
352358
public static FileType forFileExtension(File f) {
353-
String lcExt = StringUtil.lc(FileUtil.extension(f));
359+
String lcExt = StringUtil.lc(FileUtil.extension(f)); // TODO: Here, it doesn't recognize .html.erb files
354360
for (FileType tp : values())
355361
if (tp.getExtensions().contains(lcExt)) {
356362
return tp;

0 commit comments

Comments
 (0)