1
0
Fork 0
mirror of https://github.com/denoland/deno.git synced 2024-12-18 05:14:21 -05:00

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.
This commit is contained in:
David Sherret 2024-12-04 17:39:58 -05:00 committed by GitHub
parent e718e3f471
commit a26b873a7d
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 2 additions and 5 deletions

View file

@ -59,8 +59,7 @@ impl FileOrRedirect {
cache_entry: deno_cache_dir::CacheEntry,
) -> Result<Self, AnyError> {
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 {

View file

@ -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((