mirror of
https://github.com/YGGverse/Yoda.git
synced 2026-04-02 17:45:28 +00:00
remove scheme filter from strip_prefix getter, add comments
This commit is contained in:
parent
5e4f442966
commit
f64bbb719c
1 changed files with 6 additions and 8 deletions
|
|
@ -123,6 +123,7 @@ impl Request {
|
||||||
|
|
||||||
// Getters
|
// Getters
|
||||||
|
|
||||||
|
/// Get current request value in [Uri](https://docs.gtk.org/glib/struct.Uri.html) format
|
||||||
pub fn uri(&self) -> Option<Uri> {
|
pub fn uri(&self) -> Option<Uri> {
|
||||||
match Uri::parse(&self.widget.entry.text(), UriFlags::NONE) {
|
match Uri::parse(&self.widget.entry.text(), UriFlags::NONE) {
|
||||||
Ok(uri) => Some(uri),
|
Ok(uri) => Some(uri),
|
||||||
|
|
@ -130,6 +131,8 @@ impl Request {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Get current request value without system prefix
|
||||||
|
/// * the `prefix` is not `scheme`
|
||||||
pub fn strip_prefix(&self) -> GString {
|
pub fn strip_prefix(&self) -> GString {
|
||||||
let mut text = self.widget.entry.text();
|
let mut text = self.widget.entry.text();
|
||||||
|
|
||||||
|
|
@ -141,21 +144,15 @@ impl Request {
|
||||||
text = postfix.into()
|
text = postfix.into()
|
||||||
};
|
};
|
||||||
|
|
||||||
if let Some(postfix) = text.strip_prefix("file://") {
|
|
||||||
text = postfix.into()
|
|
||||||
};
|
|
||||||
|
|
||||||
if let Some(postfix) = text.strip_prefix("gemini://") {
|
|
||||||
text = postfix.into()
|
|
||||||
};
|
|
||||||
|
|
||||||
text
|
text
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Get request value in `download:` format
|
||||||
pub fn download(&self) -> GString {
|
pub fn download(&self) -> GString {
|
||||||
gformat!("download:{}", self.strip_prefix())
|
gformat!("download:{}", self.strip_prefix())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Get request value in `source:` format
|
||||||
pub fn source(&self) -> GString {
|
pub fn source(&self) -> GString {
|
||||||
gformat!("source:{}", self.strip_prefix())
|
gformat!("source:{}", self.strip_prefix())
|
||||||
}
|
}
|
||||||
|
|
@ -190,6 +187,7 @@ impl Request {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Tools
|
// Tools
|
||||||
|
|
||||||
pub fn migrate(tx: &Transaction) -> Result<(), String> {
|
pub fn migrate(tx: &Transaction) -> Result<(), String> {
|
||||||
// Migrate self components
|
// Migrate self components
|
||||||
if let Err(e) = database::init(tx) {
|
if let Err(e) = database::init(tx) {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue