fix: avoid panic if input is empty
This commit is contained in:
parent
ee399e67d4
commit
192793a6ab
1 changed files with 1 additions and 1 deletions
|
|
@ -95,7 +95,7 @@ pub fn parse_file_at_path(opts: ParseFileOptions) -> Result<bool> {
|
|||
.collect::<Vec<_>>();
|
||||
parser.parse_utf16(&source_code_utf16, None)
|
||||
}
|
||||
None if is_utf16_bom(&source_code[0..2]) => {
|
||||
None if source_code.len() >= 2 && is_utf16_bom(&source_code[0..2]) => {
|
||||
let source_code_utf16 = source_code
|
||||
.chunks_exact(2)
|
||||
.map(|chunk| u16::from_le_bytes([chunk[0], chunk[1]]))
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue