File tree Expand file tree Collapse file tree 3 files changed +25
-13
lines changed
src/app/browser/window/tab/item/page/navigation/request Expand file tree Collapse file tree 3 files changed +25
-13
lines changed Original file line number Diff line number Diff line change @@ -23,7 +23,7 @@ pub struct Info {
23
23
mime : Option < String > ,
24
24
/// Hold redirections chain with handled details
25
25
/// * the `referrer` member name is reserved for other protocols
26
- redirect : Option < Box < Redirect > > ,
26
+ redirect : Option < Redirect > ,
27
27
/// Key to relate data collected with the specific request
28
28
request : Option < String > ,
29
29
/// Hold size info
@@ -49,20 +49,16 @@ impl Info {
49
49
}
50
50
}
51
51
52
- /// Take `Self`, convert it into the new `Redirect` member,
53
- /// * return new `Self` that contain referring node
54
- fn into_redirect ( self , method : redirect:: Method ) -> Self {
52
+ pub fn into_permanent_redirect ( self ) -> Self {
55
53
let mut this = Self :: new ( ) ;
56
- this. redirect = Some ( Box :: new ( Redirect { info : self , method } ) ) ;
54
+ this. redirect = Some ( Redirect :: permanent ( self ) ) ;
57
55
this
58
56
}
59
57
60
- pub fn into_permanent_redirect ( self ) -> Self {
61
- self . into_redirect ( redirect:: Method :: Permanent )
62
- }
63
-
64
58
pub fn into_temporary_redirect ( self ) -> Self {
65
- self . into_redirect ( redirect:: Method :: Temporary )
59
+ let mut this = Self :: new ( ) ;
60
+ this. redirect = Some ( Redirect :: temporary ( self ) ) ;
61
+ this
66
62
}
67
63
68
64
// Actions
Original file line number Diff line number Diff line change @@ -202,7 +202,7 @@ impl Dialog for PreferencesDialog {
202
202
fn chain < ' a > ( b : & mut Vec < & ' a Info > , i : & ' a Info ) {
203
203
b. push ( i) ;
204
204
if let Some ( ref r) = i. redirect {
205
- chain ( b, & r. info )
205
+ chain ( b, & r. referrer )
206
206
}
207
207
}
208
208
// Collect redirections into the buffer,
Original file line number Diff line number Diff line change @@ -5,11 +5,27 @@ use super::Info;
5
5
6
6
/// Unified redirection info wrapper for the application page
7
7
pub struct Redirect {
8
- pub info : Info ,
8
+ pub referrer : Box < Info > ,
9
9
pub method : Method ,
10
10
}
11
11
12
12
impl Redirect {
13
+ // Constructors
14
+
15
+ pub fn permanent ( referrer : Info ) -> Self {
16
+ Self {
17
+ referrer : Box :: new ( referrer) ,
18
+ method : Method :: Permanent ,
19
+ }
20
+ }
21
+
22
+ pub fn temporary ( referrer : Info ) -> Self {
23
+ Self {
24
+ referrer : Box :: new ( referrer) ,
25
+ method : Method :: Temporary ,
26
+ }
27
+ }
28
+
13
29
// Getters
14
30
15
31
/// Check redirection has external target
@@ -21,6 +37,6 @@ impl Redirect {
21
37
. ok ( ) ?
22
38
. host ( )
23
39
}
24
- Some ( parse ( & self . info ) ? != parse ( cmp) ?)
40
+ Some ( parse ( & self . referrer ) ? != parse ( cmp) ?)
25
41
}
26
42
}
You can’t perform that action at this time.
0 commit comments