From e580aae83b8395aed7757d437ca1ede504204f47 Mon Sep 17 00:00:00 2001 From: yggverse Date: Mon, 3 Feb 2025 02:48:10 +0200 Subject: [PATCH] update `ggemini` api --- .../window/tab/item/client/driver/gemini.rs | 29 ++----------------- 1 file changed, 3 insertions(+), 26 deletions(-) diff --git a/src/app/browser/window/tab/item/client/driver/gemini.rs b/src/app/browser/window/tab/item/client/driver/gemini.rs index b534331b..956147cc 100644 --- a/src/app/browser/window/tab/item/client/driver/gemini.rs +++ b/src/app/browser/window/tab/item/client/driver/gemini.rs @@ -5,7 +5,7 @@ use ggemini::client::connection::response::{ }; use ggemini::client::{connection::response::data::Text, Client, Request, Response}; use gtk::glib::Bytes; -use gtk::glib::{GString, UriFlags}; +use gtk::glib::GString; use gtk::{ gdk::Texture, gdk_pixbuf::Pixbuf, @@ -333,8 +333,8 @@ fn handle( Response::Redirect(redirect) => match &redirect { // https://geminiprotocol.net/docs/protocol-specification.gmi#status-30-temporary-redirection // https://geminiprotocol.net/docs/protocol-specification.gmi#status-31-permanent-redirection - Redirect::Temporary { target } | - Redirect::Permanent { target } => match redirection_base(uri).parse_relative(target, UriFlags::NONE) { + Redirect::Temporary { .. } | + Redirect::Permanent { .. } => match redirect.to_uri(&uri) { Ok(target) => { // Increase client redirection counter let total = redirects.take() + 1; @@ -450,26 +450,3 @@ fn uri_to_title(uri: &Uri) -> GString { path } } - -// Build safe base `Uri` from the current request as the donor -// to resolve relative target `String` by Gemini specification -fn redirection_base(request: Uri) -> Uri { - Uri::build( - UriFlags::NONE, - request.scheme().as_str(), - None, // unexpected - request.host().as_deref(), - request.port(), - request.path().as_str(), - // > If a server sends a redirection in response to a request with a query string, - // > the client MUST NOT apply the query string to the new location - // > https://geminiprotocol.net/docs/protocol-specification.gmi#redirection - None, - // > A server SHOULD NOT include fragments in redirections, - // > but if one is given, and a client already has a fragment it could apply (from the original URI), - // > it is up to the client which fragment to apply. - // > https://geminiprotocol.net/docs/protocol-specification.gmi#redirection - // @TODO - None, - ) -}