Skip to content

Commit

Permalink
[minor] Fix nits
Browse files Browse the repository at this point in the history
  • Loading branch information
lpinca committed May 4, 2021
1 parent fc7e27d commit 8c914d1
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions lib/validation.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ function _isValidUTF8(buf) {
let i = 0;

while (i < len) {
if (buf[i] < 0x80) {
if ((buf[i] & 0x80) === 0) {
// 0xxxxxxx
i++;
} else if ((buf[i] & 0xe0) === 0xc0) {
Expand All @@ -43,9 +43,9 @@ function _isValidUTF8(buf) {
(buf[i] & 0xfe) === 0xc0 // Overlong
) {
return false;
} else {
i += 2;
}

i += 2;
} else if ((buf[i] & 0xf0) === 0xe0) {
// 1110xxxx 10xxxxxx 10xxxxxx
if (
Expand All @@ -56,9 +56,9 @@ function _isValidUTF8(buf) {
(buf[i] === 0xed && (buf[i + 1] & 0xe0) === 0xa0) // Surrogate (U+D800 - U+DFFF)
) {
return false;
} else {
i += 3;
}

i += 3;
} else if ((buf[i] & 0xf8) === 0xf0) {
// 11110xxx 10xxxxxx 10xxxxxx 10xxxxxx
if (
Expand All @@ -71,9 +71,9 @@ function _isValidUTF8(buf) {
buf[i] > 0xf4 // > U+10FFFF
) {
return false;
} else {
i += 4;
}

i += 4;
} else {
return false;
}
Expand Down

0 comments on commit 8c914d1

Please sign in to comment.