Skip to content

Commit 623e1a3

Browse files
committed
simplify
1 parent 3c3c8eb commit 623e1a3

File tree

1 file changed

+2
-16
lines changed

1 file changed

+2
-16
lines changed

routers/repo/view.go

Lines changed: 2 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ import (
1111
gotemplate "html/template"
1212
"io/ioutil"
1313
"path"
14-
"regexp"
1514
"strconv"
1615
"strings"
1716

@@ -211,24 +210,11 @@ func renderFile(ctx *context.Context, entry *git.TreeEntry, treeLink, rawLink st
211210
}
212211

213212
var output bytes.Buffer
214-
var terminator string
215-
216-
if strings.Index(fileContent, "\r\n") != -1 {
217-
lf, _ := regexp.MatchString(`[^\r]\n`, fileContent)
218-
if lf {
219-
terminator = "\n"
220-
} else {
221-
terminator = "\r\n"
222-
}
223-
} else {
224-
terminator = "\n"
225-
}
226-
lines := regexp.MustCompile(`\r?\n`).Split(fileContent, -1)
227-
213+
lines := strings.Split(fileContent, "\n")
228214
for index, line := range lines {
229215
line = gotemplate.HTMLEscapeString(line)
230216
if index != len(lines)-1 {
231-
line += terminator
217+
line += "\n"
232218
}
233219
output.WriteString(fmt.Sprintf(`<li class="L%d" rel="L%d">%s</li>`, index+1, index+1, line))
234220
}

0 commit comments

Comments
 (0)