commit - bbf982974ca98df9b032cfe1b76b680e68a4969a
commit + 449ea6fe32441d2fd3875c5eee5d0c77800cfa7d
blob - 7dea5c7de8a8ec4bc564380c08853cc03075e62d
blob + 34abcd824819232b05a0c8ce3b2a9b468f46a8bf
--- include/telescope.h
+++ include/telescope.h
int load_previous_page(struct tab*);
int load_next_page(struct tab*);
void write_buffer(const char *, struct tab *);
-void humanify_url(const char *, char *, size_t);
+void humanify_url(const char *, const char *, char *, size_t);
int bookmark_page(const char *);
int ui_send_net(int, uint32_t, const void *, uint16_t);
blob - b4ba4de64eeb63fa0f07375eca08b6e5428fa77c
blob + 3505c26ce050a82be817c9bde5ad177be56dc650
--- minibuffer.c
+++ minibuffer.c
#include <stdlib.h>
#include <string.h>
-#include "defaults.h"
#include "fs.h"
#include "iri.h"
#include "minibuffer.h"
lu_select(void)
{
char url[GEMINI_URL_LEN+1];
- char *base = NULL;
minibuffer_hist_save_entry();
-
- if (load_url_use_heuristic)
- humanify_url(minibuffer_compl_text(), url, sizeof(url));
- else {
- strlcpy(url, minibuffer_compl_text(), sizeof(url));
- base = current_tab->hist_cur->h;
- }
+ humanify_url(minibuffer_compl_text(), current_tab->hist_cur->h,
+ url, sizeof(url));
exit_minibuffer();
- load_url_in_tab(current_tab, url, base, LU_MODE_NOCACHE);
+ load_url_in_tab(current_tab, url, NULL, LU_MODE_NOCACHE);
}
void
blob - a662565490fa4ba9e2a8c21a02f7386513972e08
blob + 2da8f955d1f940939a6b3950f27800f1c3ed324b
--- telescope.1
+++ telescope.1
.It
otherwise assume it's a Gemini URL.
.El
+.Pp
+The setting
+.Ic load-url-use-heuristic
+can be used to disable the use of heuristics.
.Sh CONFIGURATION FILE
During the startup,
.Nm
Defaults to
.Dq about:new .
.It Ic load-url-use-heuristic
-If zero, don't use euristics for the url given to
+If zero, don't use euristics to resolve the URLs.
+Non-absolute URLs given as command line argument will be resolved as
+file system paths,
.Ic load-url
-and use the current URL as base.
+will resolve as relative to the current URL.
Defaults to 1.
.It Ic max-killed-tabs
.Pq integer
blob - a40e1ef6ad4e3b2f5760ba6403428b794d1668a5
blob + 523b39689816b53dd033316708ec647afbfe020c
--- telescope.c
+++ telescope.c
static int has_url;
static char url[GEMINI_URL_LEN];
+static char cwd[PATH_MAX];
/*
* Used to know when we're finished loading.
}
/*
- * Given a user-entered URL, apply some heuristics to use it:
+ * Given a user-entered URL, apply some heuristics to use it if
+ * load-url-use-heuristic allows it.
*
* - if it's a proper url use it
* - if it starts with a `./' or a `/' assume its a file:// url
* url.
*/
void
-humanify_url(const char *raw, char *ret, size_t len)
+humanify_url(const char *raw, const char *base, char *ret, size_t len)
{
static struct iri iri;
- char buf[PATH_MAX];
- if (iri_parse(NULL, raw, &iri) == 0) {
+ if (load_url_use_heuristic)
+ base = NULL;
+
+ if (iri_parse(base, raw, &iri) == 0) {
iri_unparse(&iri, ret, len);
return;
}
if (!strncmp(raw, "./", 2)) {
strlcpy(ret, "file://", len);
- getcwd(buf, sizeof(buf));
- strlcat(ret, buf, len);
+ strlcat(ret, cwd, len);
strlcat(ret, "/", len);
strlcat(ret, raw+2, len);
return;
if (getenv("NO_COLOR") != NULL)
enable_colors = 0;
+ if (getcwd(cwd, sizeof(cwd)) == NULL)
+ err(1, "getcwd failed");
+
while ((ch = getopt_long(argc, argv, opts, longopts, NULL)) != -1) {
switch (ch) {
case 'C':
usage(1);
}
- if (argc != 0) {
- has_url = 1;
- humanify_url(argv[0], url, sizeof(url));
- }
-
fs_init();
/* setup keys before reading the config */
(download_path = strdup("/tmp/")) == NULL)
errx(1, "strdup");
+ if (argc != 0) {
+ char *base;
+
+ if (asprintf(&base, "file://%s/", cwd) == -1)
+ err(1, "asprintf");
+
+ has_url = 1;
+ humanify_url(argv[0], base, url, sizeof(url));
+
+ free(base);
+ }
+
if (!safe_mode && (sessionfd = lock_session()) == -1) {
if (has_url) {
send_url(url);