diff --git a/src/app/browser/window/tab/item/page/navigation/request/info.rs b/src/app/browser/window/tab/item/page/navigation/request/info.rs index 07cbd4d2..e166c71c 100644 --- a/src/app/browser/window/tab/item/page/navigation/request/info.rs +++ b/src/app/browser/window/tab/item/page/navigation/request/info.rs @@ -23,7 +23,7 @@ pub struct Info { mime: Option, /// Hold redirections chain with handled details /// * the `referrer` member name is reserved for other protocols - redirect: Option>, + redirect: Option, /// Key to relate data collected with the specific request request: Option, /// Hold size info @@ -49,20 +49,16 @@ impl Info { } } - /// Take `Self`, convert it into the new `Redirect` member, - /// * return new `Self` that contain referring node - fn into_redirect(self, method: redirect::Method) -> Self { + pub fn into_permanent_redirect(self) -> Self { let mut this = Self::new(); - this.redirect = Some(Box::new(Redirect { info: self, method })); + this.redirect = Some(Redirect::permanent(self)); this } - pub fn into_permanent_redirect(self) -> Self { - self.into_redirect(redirect::Method::Permanent) - } - pub fn into_temporary_redirect(self) -> Self { - self.into_redirect(redirect::Method::Temporary) + let mut this = Self::new(); + this.redirect = Some(Redirect::temporary(self)); + this } // Actions diff --git a/src/app/browser/window/tab/item/page/navigation/request/info/dialog.rs b/src/app/browser/window/tab/item/page/navigation/request/info/dialog.rs index 5e9e1765..27252461 100644 --- a/src/app/browser/window/tab/item/page/navigation/request/info/dialog.rs +++ b/src/app/browser/window/tab/item/page/navigation/request/info/dialog.rs @@ -202,7 +202,7 @@ impl Dialog for PreferencesDialog { fn chain<'a>(b: &mut Vec<&'a Info>, i: &'a Info) { b.push(i); if let Some(ref r) = i.redirect { - chain(b, &r.info) + chain(b, &r.referrer) } } // Collect redirections into the buffer, diff --git a/src/app/browser/window/tab/item/page/navigation/request/info/redirect.rs b/src/app/browser/window/tab/item/page/navigation/request/info/redirect.rs index b60c1b1c..00845477 100644 --- a/src/app/browser/window/tab/item/page/navigation/request/info/redirect.rs +++ b/src/app/browser/window/tab/item/page/navigation/request/info/redirect.rs @@ -5,11 +5,27 @@ use super::Info; /// Unified redirection info wrapper for the application page pub struct Redirect { - pub info: Info, + pub referrer: Box, pub method: Method, } impl Redirect { + // Constructors + + pub fn permanent(referrer: Info) -> Self { + Self { + referrer: Box::new(referrer), + method: Method::Permanent, + } + } + + pub fn temporary(referrer: Info) -> Self { + Self { + referrer: Box::new(referrer), + method: Method::Temporary, + } + } + // Getters /// Check redirection has external target @@ -21,6 +37,6 @@ impl Redirect { .ok()? .host() } - Some(parse(&self.info)? != parse(cmp)?) + Some(parse(&self.referrer)? != parse(cmp)?) } }