fn resolve(
  specifier: &str,
  referrer: &ModuleSpecifier,
  range: &ast::Range,
  maybe_resolver: &Option<Box<dyn Resolver>>,
) -> Resolved {
  let mut remapped = false;
  let resolved_specifier = if let Some(resolver) = maybe_resolver {
    remapped = true;
    resolver
      .resolve(specifier, referrer)
      .map_err(ResolutionError::ResolverError)
  } else {
    resolve_import(specifier, referrer)
      .map_err(ResolutionError::InvalidSpecifier)
  };
  let span = ast::Span {
    specifier: referrer.clone(),
    range: range.clone(),
  };
  match resolved_specifier {
    Ok(specifier) => {
      let referrer_scheme = referrer.scheme();
      let specifier_scheme = specifier.scheme();
      if referrer_scheme == "https" && specifier_scheme == "http" {
        Resolved::Err(ResolutionError::InvalidDowngrade, span)
      } else if (referrer_scheme == "https" || referrer_scheme == "http")
        && !(specifier_scheme == "https" || specifier_scheme == "http")
        && !remapped
      {
        Resolved::Err(ResolutionError::InvalidLocalImport, span)
      } else {
        Resolved::Specifier(specifier, span)
      }
    }
    Err(err) => Resolved::Err(err, span),
  }
}
/// Resolve a string specifier from a referring module, using the resolver if
/// present, returning the resolution result.
Resolve a string specifier from a referring module, using the resolver if
present, returning the resolution result.
Resolve a string specifier from a referring module using the resolver if present returning the resolution result .
fn resolve(
  specifier: &str,
  referrer: &ModuleSpecifier,
  range: &ast::Range,
  maybe_resolver: &Option<Box<dyn Resolver>>,
) -> Resolved {
  let mut remapped = false;
  let resolved_specifier = if let Some(resolver) = maybe_resolver {
    remapped = true;
    resolver
      .resolve(specifier, referrer)
      .map_err(ResolutionError::ResolverError)
  } else {
    resolve_import(specifier, referrer)
      .map_err(ResolutionError::InvalidSpecifier)
  };
  let span = ast::Span {
    specifier: referrer.clone(),
    range: range.clone(),
  };
  match resolved_specifier {
    Ok(specifier) => {
      let referrer_scheme = referrer.scheme();
      let specifier_scheme = specifier.scheme();
      if referrer_scheme == "https" && specifier_scheme == "http" {
        Resolved::Err(ResolutionError::InvalidDowngrade, span)
      } else if (referrer_scheme == "https" || referrer_scheme == "http")
        && !(specifier_scheme == "https" || specifier_scheme == "http")
        && !remapped
      {
        Resolved::Err(ResolutionError::InvalidLocalImport, span)
      } else {
        Resolved::Specifier(specifier, span)
      }
    }
    Err(err) => Resolved::Err(err, span),
  }
}
fn resolve ( specifier : & str , referrer : & ModuleSpecifier , range : & ast :: Range , maybe_resolver : & Option < Box < dyn Resolver > > , ) -> Resolved { let mut remapped = false ; let resolved_specifier = if let Some ( resolver ) = maybe_resolver { remapped = true ; resolver . resolve ( specifier , referrer ) . map_err ( ResolutionError :: ResolverError ) } else { resolve_import ( specifier , referrer ) . map_err ( ResolutionError :: InvalidSpecifier ) } ; let span = ast :: Span { specifier : referrer . clone ( ) , range : range . clone ( ) , } ; match resolved_specifier { Ok ( specifier ) => { let referrer_scheme = referrer . scheme ( ) ; let specifier_scheme = specifier . scheme ( ) ; if referrer_scheme == " " && specifier_scheme == " " { Resolved :: Err ( ResolutionError :: InvalidDowngrade , span ) } else if ( referrer_scheme == " " || referrer_scheme == " " ) && ! ( specifier_scheme == " " || specifier_scheme == " " ) && ! remapped { Resolved :: Err ( ResolutionError :: InvalidLocalImport , span ) } else { Resolved :: Specifier ( specifier , span ) } } Err ( err ) => Resolved :: Err ( err , span ) , } }
Resolve a string specifier from a referring module, using the resolver if
present, returning the resolution result.
Resolve a string specifier from a referring module using the resolver if present returning the resolution result .
specifier
&str
referrer
&ModuleSpecifier
range
&ast::Range
maybe_resolver
&Option<Box<dyn Resolver>>
specifier
&str
referrer
&ModuleSpecifier
range
&ast::Range
maybe_resolver
&Option<Box<dyn Resolver>>