From 5fc5e7b54a9fba421dfc473016625a4f592403ed Mon Sep 17 00:00:00 2001 From: Maayan Hanin Date: Tue, 4 Aug 2020 00:39:48 +0300 Subject: fix(cli): add support for non-UTF8 source files (#6789) Fixes: #5542 --- cli/module_graph.rs | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'cli/module_graph.rs') diff --git a/cli/module_graph.rs b/cli/module_graph.rs index 3fb1379f3..8b7a52906 100644 --- a/cli/module_graph.rs +++ b/cli/module_graph.rs @@ -458,7 +458,7 @@ impl ModuleGraphLoader { redirect: Some(source_file.url.to_string()), filename: source_file.filename.to_str().unwrap().to_string(), version_hash: checksum::gen(&[ - &source_file.source_code, + &source_file.source_code.as_bytes(), version::DENO.as_bytes(), ]), media_type: source_file.media_type, @@ -473,9 +473,11 @@ impl ModuleGraphLoader { } let module_specifier = ModuleSpecifier::from(source_file.url.clone()); - let version_hash = - checksum::gen(&[&source_file.source_code, version::DENO.as_bytes()]); - let source_code = String::from_utf8(source_file.source_code)?; + let version_hash = checksum::gen(&[ + &source_file.source_code.as_bytes(), + version::DENO.as_bytes(), + ]); + let source_code = source_file.source_code.to_string()?; if SUPPORTED_MEDIA_TYPES.contains(&source_file.media_type) { if let Some(types_specifier) = source_file.types_header { -- cgit v1.2.3