From a26b873a7d269212db10a157bc9fdb49b6b83f52 Mon Sep 17 00:00:00 2001 From: David Sherret Date: Wed, 4 Dec 2024 17:39:58 -0500 Subject: [PATCH] refactor: remove usages of `deno_core::resolve_import` for resolving redirects (#27234) This was doing an allocation for reparsing the specifier. Might as well do `.join` here and it means I can extract out this file fetcher code to deno_cache_dir more easily. --- cli/file_fetcher.rs | 3 +-- cli/lsp/resolver.rs | 4 +--- 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/cli/file_fetcher.rs b/cli/file_fetcher.rs index f0adc60e3b..29f9c6ba3f 100644 --- a/cli/file_fetcher.rs +++ b/cli/file_fetcher.rs @@ -59,8 +59,7 @@ impl FileOrRedirect { cache_entry: deno_cache_dir::CacheEntry, ) -> Result { if let Some(redirect_to) = cache_entry.metadata.headers.get("location") { - let redirect = - deno_core::resolve_import(redirect_to, specifier.as_str())?; + let redirect = specifier.join(redirect_to)?; Ok(FileOrRedirect::Redirect(redirect)) } else { Ok(FileOrRedirect::File(File { diff --git a/cli/lsp/resolver.rs b/cli/lsp/resolver.rs index 2434501a1b..363ad43700 100644 --- a/cli/lsp/resolver.rs +++ b/cli/lsp/resolver.rs @@ -941,9 +941,7 @@ impl RedirectResolver { if chain.len() > 10 { break None; } - let Ok(target) = - deno_core::resolve_import(location, specifier.as_str()) - else { + let Ok(target) = specifier.join(location) else { break None; }; chain.push((