Fix Codacy issue in ServerSpec

This commit is contained in:
Dale Wijnand 2018-01-31 10:20:33 +00:00
parent b228af3cf1
commit a9bdcc4f0f
No known key found for this signature in database
GPG Key ID: 4F256E3D151DF5EF
1 changed files with 2 additions and 3 deletions

View File

@ -108,9 +108,8 @@ object ServerSpec {
val chunk0 = buffer.take(delimPos)
buffer = buffer.drop(delimPos + 1)
// remove \r at the end of line.
if (chunk0.size > 0 && chunk0.indexOf(RetByte) == chunk0.size - 1)
Some(new String(chunk0.dropRight(1).toArray, "utf-8"))
else Some(new String(chunk0.toArray, "utf-8"))
val chunk1 = if (chunk0.isEmpty || chunk0.last != RetByte) chunk0 else chunk0.dropRight(1)
Some(new String(chunk1.toArray, "utf-8"))
} else None // no EOL yet, so skip this turn.
}