Skip to content

Commit 3d93fb1

Browse files
authored
fix: convert file path with special characters to url correctly (#490)
1 parent 89e59b0 commit 3d93fb1

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

crates/graph/graph_util.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ use crate::emitter::EmitterFactory;
22
use crate::graph_fs::DenoGraphFsAdapter;
33
use crate::jsr::CliJsrUrlProvider;
44
use crate::resolver::CliGraphResolver;
5-
use anyhow::Context;
5+
use anyhow::{anyhow, Context};
66
use deno_core::error::{custom_error, AnyError};
77
use deno_core::parking_lot::Mutex;
88
use deno_core::{FastString, ModuleSpecifier};
@@ -413,10 +413,9 @@ pub async fn create_graph(
413413
specifier
414414
} else {
415415
let binding = std::fs::canonicalize(&file).context("failed to read path")?;
416-
let specifier = binding.to_str().context("failed to convert path to str")?;
417-
let format_specifier = format!("file:///{}", specifier);
418416

419-
ModuleSpecifier::parse(&format_specifier).context("failed to parse specifier")?
417+
ModuleSpecifier::from_file_path(binding)
418+
.map_err(|_| anyhow!("failed to parse specifier"))?
420419
};
421420

422421
let builder = ModuleGraphBuilder::new(emitter_factory, false);

0 commit comments

Comments
 (0)