mirror of
https://github.com/YGGverse/Yoda.git
synced 2025-03-13 06:01:21 +00:00
draft request router
This commit is contained in:
parent
fd73dc3d7c
commit
85115c1267
@ -1,4 +1,7 @@
|
||||
use gtk::{glib::GString, Box, Orientation};
|
||||
use gtk::{
|
||||
glib::{GString, Regex, RegexCompileFlags, RegexMatchFlags, Uri, UriFlags},
|
||||
Box, Orientation,
|
||||
};
|
||||
|
||||
pub struct Content {
|
||||
widget: Box,
|
||||
@ -14,6 +17,28 @@ impl Content {
|
||||
|
||||
// Actions
|
||||
pub fn reload(&self, request_text: GString) {
|
||||
/*let _uri = */
|
||||
match Uri::parse(&request_text, UriFlags::NONE) {
|
||||
Ok(uri) => {
|
||||
println!("Parsed URI: {}", uri); // @TODO
|
||||
}
|
||||
Err(_) => {
|
||||
// Request contain host substring
|
||||
if Regex::match_simple(
|
||||
r"regex(^[^\/\s]+\.[\w]{2,})regex",
|
||||
request_text.clone(),
|
||||
RegexCompileFlags::DEFAULT,
|
||||
RegexMatchFlags::DEFAULT,
|
||||
) {
|
||||
let request_text = format!("gemini://{request_text}");
|
||||
// @TODO reload
|
||||
} else {
|
||||
Uri::escape_string(&request_text, None, false);
|
||||
let request_text = format!("gemini://tlgs.one/search?{request_text}");
|
||||
// @TODO reload
|
||||
}
|
||||
}
|
||||
};
|
||||
// @TODO
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user