mirror of
https://codeberg.org/dnkl/foot.git
synced 2026-04-10 08:20:59 -04:00
Revert "url-mode: don't strip the file:// prefix from localhost URIs"
This reverts commit 54722369d8.
This commit is contained in:
parent
511aad419b
commit
996e5fa630
1 changed files with 31 additions and 2 deletions
33
url-mode.c
33
url-mode.c
|
|
@ -129,17 +129,46 @@ static void
|
||||||
activate_url(struct seat *seat, struct terminal *term, const struct url *url,
|
activate_url(struct seat *seat, struct terminal *term, const struct url *url,
|
||||||
uint32_t serial)
|
uint32_t serial)
|
||||||
{
|
{
|
||||||
|
char *url_string = NULL;
|
||||||
|
|
||||||
|
char *scheme, *host, *path;
|
||||||
|
if (uri_parse(url->url, strlen(url->url), &scheme, NULL, NULL,
|
||||||
|
&host, NULL, &path, NULL, NULL))
|
||||||
|
{
|
||||||
|
if (strcmp(scheme, "file") == 0 && hostname_is_localhost(host)) {
|
||||||
|
/*
|
||||||
|
* This is a file in *this* computer. Pass only the
|
||||||
|
* filename to the URL-launcher.
|
||||||
|
*
|
||||||
|
* I.e. strip the ‘file://user@host/’ prefix.
|
||||||
|
*/
|
||||||
|
url_string = path;
|
||||||
|
} else
|
||||||
|
free(path);
|
||||||
|
|
||||||
|
free(scheme);
|
||||||
|
free(host);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (url_string == NULL)
|
||||||
|
url_string = xstrdup(url->url);
|
||||||
|
|
||||||
switch (url->action) {
|
switch (url->action) {
|
||||||
case URL_ACTION_COPY:
|
case URL_ACTION_COPY:
|
||||||
text_to_clipboard(seat, term, xstrdup(url->url), seat->kbd.serial);
|
if (text_to_clipboard(seat, term, url_string, seat->kbd.serial)) {
|
||||||
|
/* Now owned by our clipboard “manager” */
|
||||||
|
url_string = NULL;
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case URL_ACTION_LAUNCH:
|
case URL_ACTION_LAUNCH:
|
||||||
case URL_ACTION_PERSISTENT: {
|
case URL_ACTION_PERSISTENT: {
|
||||||
spawn_url_launcher(seat, term, url->url, serial);
|
spawn_url_launcher(seat, term, url_string, serial);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
free(url_string);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue