diff options
author | Maayan Hanin <maayan.asa.hanin@gmail.com> | 2020-08-04 00:39:48 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-08-03 23:39:48 +0200 |
commit | 5fc5e7b54a9fba421dfc473016625a4f592403ed (patch) | |
tree | e66bbbdaa30b34b7cef8072ded8ea3f0575c47f0 /cli/module_graph.rs | |
parent | d615ebefe2e306f2877afb40dc603f71263407d6 (diff) |
fix(cli): add support for non-UTF8 source files (#6789)
Fixes: #5542
Diffstat (limited to 'cli/module_graph.rs')
-rw-r--r-- | cli/module_graph.rs | 10 |
1 files changed, 6 insertions, 4 deletions
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 { |