mirror of
https://github.com/denoland/deno.git
synced 2025-01-21 04:52:26 -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:
parent
e718e3f471
commit
a26b873a7d
2 changed files with 2 additions and 5 deletions
|
@ -59,8 +59,7 @@ impl FileOrRedirect {
|
||||||
cache_entry: deno_cache_dir::CacheEntry,
|
cache_entry: deno_cache_dir::CacheEntry,
|
||||||
) -> Result<Self, AnyError> {
|
) -> Result<Self, AnyError> {
|
||||||
if let Some(redirect_to) = cache_entry.metadata.headers.get("location") {
|
if let Some(redirect_to) = cache_entry.metadata.headers.get("location") {
|
||||||
let redirect =
|
let redirect = specifier.join(redirect_to)?;
|
||||||
deno_core::resolve_import(redirect_to, specifier.as_str())?;
|
|
||||||
Ok(FileOrRedirect::Redirect(redirect))
|
Ok(FileOrRedirect::Redirect(redirect))
|
||||||
} else {
|
} else {
|
||||||
Ok(FileOrRedirect::File(File {
|
Ok(FileOrRedirect::File(File {
|
||||||
|
|
|
@ -941,9 +941,7 @@ impl RedirectResolver {
|
||||||
if chain.len() > 10 {
|
if chain.len() > 10 {
|
||||||
break None;
|
break None;
|
||||||
}
|
}
|
||||||
let Ok(target) =
|
let Ok(target) = specifier.join(location) else {
|
||||||
deno_core::resolve_import(location, specifier.as_str())
|
|
||||||
else {
|
|
||||||
break None;
|
break None;
|
||||||
};
|
};
|
||||||
chain.push((
|
chain.push((
|
||||||
|
|
Loading…
Add table
Reference in a new issue