mirror of
https://github.com/YGGverse/Yoda.git
synced 2025-09-11 22:42:00 +00:00
try parse Uri
from request if parsed object not provided
This commit is contained in:
parent
d10987ff4e
commit
23cc695896
@ -919,14 +919,22 @@ fn is_external_uri(subject: &Uri, base: &Uri) -> bool {
|
|||||||
subject.host() != base.host()
|
subject.host() != base.host()
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Make new history record for given `navigation` object
|
/// Make new history record in related components
|
||||||
/// * applies on shared conditions match only
|
/// * optional [Uri](https://docs.gtk.org/glib/struct.Uri.html) reference wanted only for performance reasons, to not parse it twice
|
||||||
fn snap_history(profile: &Profile, navigation: &Navigation, uri: Option<&Uri>) {
|
fn snap_history(profile: &Profile, navigation: &Navigation, uri: Option<&Uri>) {
|
||||||
let request = navigation.request.widget.entry.text();
|
let request = navigation.request.widget.entry.text();
|
||||||
|
|
||||||
// Add new record into the global memory index (used in global menu)
|
// Add new record into the global memory index (used in global menu)
|
||||||
if let Some(uri) = uri {
|
// * if the `Uri` is `None`, try parse it from `request`
|
||||||
profile.history.memory.request.set(uri);
|
match uri {
|
||||||
|
Some(uri) => profile.history.memory.request.set(uri.clone()),
|
||||||
|
None => {
|
||||||
|
// this case especially useful for some routes that contain redirects
|
||||||
|
// maybe some parental optimization wanted @TODO
|
||||||
|
if let Some(uri) = navigation.request.uri() {
|
||||||
|
profile.history.memory.request.set(uri);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add new record into the page navigation history
|
// Add new record into the page navigation history
|
||||||
|
@ -32,12 +32,12 @@ impl Request {
|
|||||||
|
|
||||||
/// Add new record with `request` as key and `unix_timestamp` as value
|
/// Add new record with `request` as key and `unix_timestamp` as value
|
||||||
/// * replace with new value if `request` already exists
|
/// * replace with new value if `request` already exists
|
||||||
pub fn set(&self, uri: &Uri) {
|
pub fn set(&self, uri: Uri) {
|
||||||
self.index.borrow_mut().insert(
|
self.index.borrow_mut().insert(
|
||||||
uri.to_str(),
|
uri.to_str(),
|
||||||
Value {
|
Value {
|
||||||
unix_timestamp: DateTime::now_local().unwrap().to_unix(),
|
unix_timestamp: DateTime::now_local().unwrap().to_unix(),
|
||||||
uri: uri.clone(),
|
uri,
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user