commit 36f94f06b08270ab5d4465aa61ae025c98e24c2c from: Omar Polo date: Fri Dec 23 22:11:18 2022 UTC use the new iri parser in ir_select_gemini While here also add some error checking. commit - 46102ea3153564d16a0ab489cbecb67025e29aea commit + 36f94f06b08270ab5d4465aa61ae025c98e24c2c blob - aca82a24187775201b6e0deb3994b792c18c9099 blob + 2d9a872abf6fe7e335474c0504f25b6f685d18ac --- minibuffer.c +++ minibuffer.c @@ -23,6 +23,7 @@ #include #include "fs.h" +#include "iri.h" #include "minibuffer.h" #include "session.h" #include "ui.h" @@ -278,19 +279,25 @@ eecmd_select(void) void ir_select_gemini(void) { - char buf[1025] = {0}; - struct phos_uri uri; + static struct iri iri; + char buf[1025]; struct tab *tab = current_tab; minibuffer_hist_save_entry(); - /* a bit ugly but... */ - memcpy(&uri, &tab->uri, sizeof(tab->uri)); - phos_uri_set_query(&uri, minibuffer_compl_text()); - phos_serialize_uri(&uri, buf, sizeof(buf)); + if (iri_parse(NULL, tab->hist_cur->h, &iri) == -1) + goto err; + if (iri_setquery(&iri, minibuffer_compl_text()) == -1) + goto err; + if (iri_unparse(&iri, buf, sizeof(buf)) == -1) + goto err; exit_minibuffer(); load_url_in_tab(tab, buf, NULL, LU_MODE_NOCACHE); + return; + + err: + message("Failed to select URL."); } void