From f64bbb719cb0257b17062de1bad19250cf43292b Mon Sep 17 00:00:00 2001 From: yggverse Date: Fri, 13 Dec 2024 02:12:54 +0200 Subject: [PATCH] remove `scheme` filter from `strip_prefix` getter, add comments --- .../window/tab/item/page/navigation/request.rs | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/src/app/browser/window/tab/item/page/navigation/request.rs b/src/app/browser/window/tab/item/page/navigation/request.rs index f556a596..503a6935 100644 --- a/src/app/browser/window/tab/item/page/navigation/request.rs +++ b/src/app/browser/window/tab/item/page/navigation/request.rs @@ -123,6 +123,7 @@ impl Request { // Getters + /// Get current request value in [Uri](https://docs.gtk.org/glib/struct.Uri.html) format pub fn uri(&self) -> Option { match Uri::parse(&self.widget.entry.text(), UriFlags::NONE) { 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 { let mut text = self.widget.entry.text(); @@ -141,21 +144,15 @@ impl Request { 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 } + /// Get request value in `download:` format pub fn download(&self) -> GString { gformat!("download:{}", self.strip_prefix()) } + /// Get request value in `source:` format pub fn source(&self) -> GString { gformat!("source:{}", self.strip_prefix()) } @@ -190,6 +187,7 @@ impl Request { } // Tools + pub fn migrate(tx: &Transaction) -> Result<(), String> { // Migrate self components if let Err(e) = database::init(tx) {