mirror of
https://github.com/YGGverse/Yoda.git
synced 2025-01-15 09:10:08 +00:00
move strip_prefix getter to request api
This commit is contained in:
parent
4e0797bd6e
commit
6f038539d6
@ -72,7 +72,7 @@ impl Navigation {
|
||||
self.bookmark
|
||||
.update(self.profile.bookmark.get(&request_text).is_ok());
|
||||
self.history.update();
|
||||
self.home.update(&request_text);
|
||||
self.home.update(&self.request.strip_prefix());
|
||||
self.reload.update(!request_text.is_empty());
|
||||
self.request.update(
|
||||
progress_fraction,
|
||||
|
@ -24,7 +24,7 @@ impl Home {
|
||||
|
||||
// Actions
|
||||
pub fn update(&self, request: &str) {
|
||||
let has_home = match Uri::parse(strip_prefix(request), UriFlags::NONE) {
|
||||
let has_home = match Uri::parse(request, UriFlags::NONE) {
|
||||
Ok(uri) => {
|
||||
let has_home = "/" != uri.path();
|
||||
self.uri.replace(Some(uri));
|
||||
@ -56,19 +56,3 @@ impl Home {
|
||||
None
|
||||
}
|
||||
}
|
||||
|
||||
// Tools
|
||||
|
||||
fn strip_prefix(request: &str) -> &str {
|
||||
let request = match request.strip_prefix("source:") {
|
||||
Some(postfix) => postfix,
|
||||
None => request,
|
||||
};
|
||||
|
||||
let request = match request.strip_prefix("download:") {
|
||||
Some(postfix) => postfix,
|
||||
None => request,
|
||||
};
|
||||
|
||||
request
|
||||
}
|
||||
|
@ -5,7 +5,7 @@ use widget::Widget;
|
||||
|
||||
use crate::app::browser::{window::tab::item::Action as TabAction, Action as BrowserAction};
|
||||
use gtk::{
|
||||
glib::{Uri, UriFlags},
|
||||
glib::{GString, Uri, UriFlags},
|
||||
prelude::EditableExt,
|
||||
};
|
||||
use sqlite::Transaction;
|
||||
@ -96,6 +96,20 @@ impl Request {
|
||||
_ => None,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn strip_prefix(&self) -> GString {
|
||||
let mut text = self.widget.entry.text();
|
||||
|
||||
if let Some(postfix) = text.strip_prefix("source:") {
|
||||
text = postfix.into()
|
||||
};
|
||||
|
||||
if let Some(postfix) = text.strip_prefix("download:") {
|
||||
text = postfix.into()
|
||||
};
|
||||
|
||||
text
|
||||
}
|
||||
}
|
||||
|
||||
// Tools
|
||||
|
Loading…
x
Reference in New Issue
Block a user