diff --git a/lychee-lib/src/utils/request.rs b/lychee-lib/src/utils/request.rs index b26f5ba466..04c8c56d5d 100644 --- a/lychee-lib/src/utils/request.rs +++ b/lychee-lib/src/utils/request.rs @@ -62,19 +62,36 @@ fn try_parse_into_uri( text = path.to_owned() + &text; } } + println!("text: {}", text); let uri = match Uri::try_from(raw_uri.clone()) { - Ok(uri) => uri, + Ok(uri) => { + println!("uri: {:?}", uri); + uri + }, Err(_) => match base { Some(base_url) => match base_url.join(&text) { - Some(url) => Uri { url }, - None => return Err(ErrorKind::InvalidBaseJoin(text.clone())), + Some(url) => { + println!("url: {:?}", url); + Uri { url } + }, + None => { + println!("Error: {:?}", ErrorKind::InvalidBaseJoin(text.clone())); + return Err(ErrorKind::InvalidBaseJoin(text.clone())) + }, }, None => match source { - InputSource::FsPath(root) => create_uri_from_file_path(root, &text, base)?, - _ => return Err(ErrorKind::UnsupportedUriType(text)), + InputSource::FsPath(root) => { + println!("======================================="); + create_uri_from_file_path(root, &text, &None)? + }, + _ => { + println!("Error: {:?}", ErrorKind::UnsupportedUriType(text.clone())); + return Err(ErrorKind::UnsupportedUriType(text)) + }, }, }, }; + println!("RETURNING uri: {:?}", uri); Ok(uri) } @@ -95,6 +112,8 @@ fn create_uri_from_file_path( link_text: &str, base: &Option, ) -> Result { + println!("file_path: {:?}", file_path); + println!("link_text: {:?}", link_text); let target_path = if is_anchor(link_text) { // For anchors, we need to append the anchor to the file name. let file_name = file_path @@ -106,6 +125,7 @@ fn create_uri_from_file_path( } else { link_text.to_string() }; + println!("link_text: {:?}", link_text); let Ok(constructed_url) = resolve_and_create_url(file_path, &target_path, base) else { return Err(ErrorKind::InvalidPathToUri(target_path)); }; @@ -173,6 +193,9 @@ fn resolve_and_create_url( dest_path: &str, base_uri: &Option, ) -> Result { + println!("resolve_and_create_url"); + println!("src_path: {:?}", src_path); + println!("dest_path: {:?}", dest_path); let (dest_path, fragment) = url::remove_get_params_and_separate_fragment(dest_path); // Decode the destination path to avoid double-encoding @@ -181,13 +204,16 @@ fn resolve_and_create_url( let Ok(Some(resolved_path)) = path::resolve(src_path, &PathBuf::from(&*decoded_dest), base_uri) else { + println!("Error: {:?}", ErrorKind::InvalidPathToUri(decoded_dest.to_string())); return Err(ErrorKind::InvalidPathToUri(decoded_dest.to_string())); }; let Ok(mut url) = Url::from_file_path(&resolved_path) else { + println!("Error: {:?}", ErrorKind::InvalidUrlFromPath(resolved_path.clone())); return Err(ErrorKind::InvalidUrlFromPath(resolved_path.clone())); }; + println!("OK!"); url.set_fragment(fragment); Ok(url) }