Merge pull request #24 from erizocosmico/fix/bail-out-if-not-enough-lines

data: bailout in some cases if there arent enough lines
This commit is contained in:
Máximo Cuadros 2020-05-28 16:45:10 +02:00 committed by GitHub
commit dc6fc02209
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -209,6 +209,9 @@ func isCompiledCoffeeScript(path, ext string, content []byte) bool {
firstLine := getFirstLine(content)
lastLines := getLines(content, -2)
if len(lastLines) < 2 {
return false
}
if string(firstLine) == "(function() {" &&
string(lastLines[1]) == "}).call(this);" &&
@ -675,11 +678,13 @@ func isGeneratedHTML(_, ext string, content []byte) bool {
lines := getLines(content, 30)
// Pkgdown
if len(lines) >= 2 {
for _, l := range lines[:2] {
if bytes.Contains(l, []byte("<!-- Generated by pkgdown: do not edit by hand -->")) {
return true
}
}
}
// Mandoc
if len(lines) > 2 &&