Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 3 additions & 7 deletions crates/rwalk/src/utils/format.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use std::{borrow::Cow, fmt::Display};
use std::fmt::Display;

use owo_colors::OwoColorize;

Expand All @@ -8,7 +8,7 @@ pub fn response(response: &RwalkResponse, show: &[String]) -> String {
format!(
"{} {} {} {}",
display_status_code(response.status as u16),
display_url(response.url.as_str()),
response.url.as_str(),
display_time(response.time),
{
let showed = response.display_show(show);
Expand All @@ -21,10 +21,6 @@ pub fn response(response: &RwalkResponse, show: &[String]) -> String {
)
}

fn display_url(url: &str) -> Cow<'_, str> {
urlencoding::decode(url).unwrap_or(url.into())
}

pub fn display_time(t: i64) -> String {
let t = t as f64 / 1_000.0;
let mut unit: &str = "ms";
Expand Down Expand Up @@ -143,7 +139,7 @@ pub fn skip(response: &RwalkResponse, reason: SkipReason, show: &[String]) -> St
"{} {} {} {} {} {}",
"↷".blue(),
response.status.dimmed(),
display_url(response.url.as_str()),
response.url.as_str(),
display_time(response.time),
format!("({})", reason).dimmed(),
{
Expand Down
13 changes: 9 additions & 4 deletions crates/rwalk/src/wordlist/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ use crossbeam::deque::Injector;
use rayon::iter::{IntoParallelRefIterator, IntoParallelRefMutIterator, ParallelIterator};
use transformation::Transformer;
use url::Url;
use url::Position;

pub mod filters;
pub mod processor;
Expand Down Expand Up @@ -44,11 +45,15 @@ impl Wordlist {
}

pub fn inject_into(&self, injector: &Injector<Task>, url: &Url, depth: usize) -> Result<()> {
let base_url = url.clone();
let base_prefix = url[..Position::BeforePath].to_string();

self.words.par_iter().try_for_each(|word| {
let mut url = base_url.clone();
url.path_segments_mut().unwrap().pop_if_empty().push(word);
injector.push(Task::new_recursive(url.to_string(), depth));
let full_url = if base_prefix.ends_with('/') || word.starts_with('/') {
format!("{}{}", base_prefix.trim_end_matches('/'), word)
} else {
format!("{}/{}", base_prefix, word)
};
injector.push(Task::new_recursive(full_url, depth));
Ok(())
})
}
Expand Down