pub(crate) async fn parse_and_resolve_url(
        &mut self,
        url: &str,
    ) -> Result<(SafeUrl, Option<SafeUrl>)> {
        let safe_url = Safe::parse_url(url)?;
        let orig_path = safe_url.path_decoded()?;

        // Obtain the resolution chain without resolving the URL's path
        let mut resolution_chain = self
            .retrieve_from_url(
                &safe_url.to_string(),
                false,
                None,
                false, // don't resolve the URL's path
            )
            .await?;

        // The resolved content is the last item in the resolution chain we obtained
        let safe_data = resolution_chain
            .pop()
            .ok_or_else(|| Error::ContentNotFound(format!("Failed to resolve {}", url)))?;

        // Set the original path so we return the SafeUrl with it
        let mut safe_url = SafeUrl::from_url(&safe_data.xorurl())?;
        safe_url.set_path(&orig_path);

        // If there is still one item in the chain, the first item is the NRS Map Container
        // targeted by the URL and where the whole resolution started from
        if resolution_chain.is_empty() {
            Ok((safe_url, None))
        } else {
            let nrsmap_xorul_encoder = SafeUrl::from_url(&resolution_chain[0].resolved_from())?;
            Ok((safe_url, Some(nrsmap_xorul_encoder)))
        }
    }
// Parses a safe:// URL and returns all the info in a SafeUrl instance.
// It also returns a second SafeUrl if the URL was resolved from an NRS-URL,
// this second SafeUrl instance contains the information of the parsed NRS-URL.
// *Note* this is not part of the public API, but an internal helper function used by API impl.
Parses a safe:// URL and returns all the info in a SafeUrl instance.
It also returns a second SafeUrl if the URL was resolved from an NRS-URL,
this second SafeUrl instance contains the information of the parsed NRS-URL.
Note* this is not part of the public API, but an internal helper function used by API impl.
Parses a safe : // URL and returns all the info in a SafeUrl instance . It also returns a second SafeUrl if the URL was resolved from an NRS - URL this second SafeUrl instance contains the information of the parsed NRS - URL . Note * this is not part of the public API but an internal helper function used by API impl .
pub(crate) async fn parse_and_resolve_url(
        &mut self,
        url: &str,
    ) -> Result<(SafeUrl, Option<SafeUrl>)> {
        let safe_url = Safe::parse_url(url)?;
        let orig_path = safe_url.path_decoded()?;
        // Obtain the resolution chain without resolving the URL's path
        let mut resolution_chain = self
            .retrieve_from_url(
                &safe_url.to_string(),
                false,
                None,
                false, // don't resolve the URL's path
            )
            .await?;
        // The resolved content is the last item in the resolution chain we obtained
        let safe_data = resolution_chain
            .pop()
            .ok_or_else(|| Error::ContentNotFound(format!("Failed to resolve {}", url)))?;
        // Set the original path so we return the SafeUrl with it
        let mut safe_url = SafeUrl::from_url(&safe_data.xorurl())?;
        safe_url.set_path(&orig_path);
        // If there is still one item in the chain, the first item is the NRS Map Container
        // targeted by the URL and where the whole resolution started from
        if resolution_chain.is_empty() {
            Ok((safe_url, None))
        } else {
            let nrsmap_xorul_encoder = SafeUrl::from_url(&resolution_chain[0].resolved_from())?;
            Ok((safe_url, Some(nrsmap_xorul_encoder)))
        }
    }
pub ( crate ) async fn parse_and_resolve_url ( & mut self , url : & str , ) -> Result < ( SafeUrl , Option < SafeUrl > ) > { let safe_url = Safe :: parse_url ( url ) ? ; let orig_path = safe_url . path_decoded ( ) ? ; // Obtain the resolution chain without resolving the URL's path let mut resolution_chain = self . retrieve_from_url ( & safe_url . to_string ( ) , false , None , false , // don't resolve the URL's path ) . await ? ; // The resolved content is the last item in the resolution chain we obtained let safe_data = resolution_chain . pop ( ) . ok_or_else ( | | Error :: ContentNotFound ( format ! ( " " url ) ) ) ? ; // Set the original path so we return the SafeUrl with it let mut safe_url = SafeUrl :: from_url ( & safe_data . xorurl ( ) ) ? ; safe_url . set_path ( & orig_path ) ; // If there is still one item in the chain, the first item is the NRS Map Container // targeted by the URL and where the whole resolution started from if resolution_chain . is_empty ( ) { Ok ( ( safe_url , None ) ) } else { let nrsmap_xorul_encoder = SafeUrl :: from_url ( & resolution_chain [ 0 ] . resolved_from ( ) ) ? ; Ok ( ( safe_url , Some ( nrsmap_xorul_encoder ) ) ) } }
Parses a safe:// URL and returns all the info in a SafeUrl instance.
Parses a safe : // URL and returns all the info in a SafeUrl instance .
&mut self
url
&str