Revert "url-mode: don't strip the file:// prefix from localhost URIs"

This reverts commit 54722369d8.
This commit is contained in:
Daniel Eklöf 2024-10-23 08:46:30 +02:00
parent 511aad419b
commit 996e5fa630
No known key found for this signature in database
GPG key ID: 5BBD4992C116573F

View file

@ -129,17 +129,46 @@ static void
activate_url(struct seat *seat, struct terminal *term, const struct url *url,
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) {
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;
case URL_ACTION_LAUNCH:
case URL_ACTION_PERSISTENT: {
spawn_url_launcher(seat, term, url->url, serial);
spawn_url_launcher(seat, term, url_string, serial);
break;
}
}
free(url_string);
}
void