diff options
author | Tommy Nguyen <remyabel@gmail.com> | 2018-08-20 09:16:35 -0400 |
---|---|---|
committer | Tommy Nguyen <remyabel@gmail.com> | 2018-08-20 09:16:35 -0400 |
commit | 45fea837713e3f471813596209cd78398df115fc (patch) | |
tree | 64ad4ef1a91bb8c020f1e8f11cd816c27c5e69d0 | |
parent | 5dd049eb821f25573ba63b70dc7c08587444f5f8 (diff) |
Convert \r\n to \n; don't depend on unix2dos
-rw-r--r-- | pkg/utils/utils.go | 2 | ||||
-rw-r--r-- | pkg/utils/utils_test.go | 7 | ||||
-rw-r--r-- | test/repos/bom.sh | 6 |
3 files changed, 9 insertions, 6 deletions
diff --git a/pkg/utils/utils.go b/pkg/utils/utils.go index f56ea8884..511de1af1 100644 --- a/pkg/utils/utils.go +++ b/pkg/utils/utils.go @@ -66,7 +66,7 @@ func TrimTrailingNewline(str string) string { // NormalizeLinefeeds - Removes all Windows and Mac style line feeds func NormalizeLinefeeds(str string) string { - str = strings.Replace(str, "\r\n", "", -1) + str = strings.Replace(str, "\r\n", "\n", -1) str = strings.Replace(str, "\r", "", -1) return str } diff --git a/pkg/utils/utils_test.go b/pkg/utils/utils_test.go index 2d5a25fcd..46b264945 100644 --- a/pkg/utils/utils_test.go +++ b/pkg/utils/utils_test.go @@ -91,7 +91,12 @@ func TestNormalizeLinefeeds(t *testing.T) { { // \r\n []byte{97, 115, 100, 102, 13, 10}, - []byte{97, 115, 100, 102}, + []byte{97, 115, 100, 102, 10}, + }, + { + // bash\r\nblah + []byte{97, 115, 100, 102, 13, 10, 97, 115, 100, 102}, + []byte{97, 115, 100, 102, 10, 97, 115, 100, 102}, }, { // \r diff --git a/test/repos/bom.sh b/test/repos/bom.sh index e8642491a..190f501a1 100644 --- a/test/repos/bom.sh +++ b/test/repos/bom.sh @@ -4,12 +4,10 @@ set -ex; rm -rf repo; mkdir repo; cd repo git init cat <<EOT >> windowslf.txt -asdf -asdf +asdf
+asdf
EOT -unix2dos windowslf.txt - cat <<EOT >> linuxlf.txt asdf asdf |