Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(graph): convert file path with special characters to url correctly #490

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 3 additions & 4 deletions crates/graph/graph_util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use crate::emitter::EmitterFactory;
use crate::graph_fs::DenoGraphFsAdapter;
use crate::jsr::CliJsrUrlProvider;
use crate::resolver::CliGraphResolver;
use anyhow::Context;
use anyhow::{anyhow, Context};
use deno_core::error::{custom_error, AnyError};
use deno_core::parking_lot::Mutex;
use deno_core::{FastString, ModuleSpecifier};
Expand Down Expand Up @@ -413,10 +413,9 @@ pub async fn create_graph(
specifier
} else {
let binding = std::fs::canonicalize(&file).context("failed to read path")?;
let specifier = binding.to_str().context("failed to convert path to str")?;
let format_specifier = format!("file:///{}", specifier);

ModuleSpecifier::parse(&format_specifier).context("failed to parse specifier")?
ModuleSpecifier::from_file_path(binding)
.map_err(|_| anyhow!("failed to parse specifier"))?
};

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