mirror of
https://github.com/kovidgoyal/kitty.git
synced 2024-09-11 14:45:31 +03:00
Make NETLOC avaialble to open action commandlines
This commit is contained in:
parent
b3ea6526e7
commit
c0f820443b
@ -64,6 +64,9 @@ some special variables, documented below:
|
||||
``FRAGMENT``
|
||||
The fragment (unquoted), if any of the URL or the empty string.
|
||||
|
||||
``NETLOC``
|
||||
The net location aka hostname (unquoted), if any of the URL or the empty string.
|
||||
|
||||
``URL_PATH``
|
||||
The path, query and fragment portions of the URL, without any
|
||||
unquoting.
|
||||
|
@ -69,7 +69,7 @@ def parse(lines: Iterable[str]) -> Iterator[OpenAction]:
|
||||
entries.append((tuple(match_criteria), tuple(raw_actions)))
|
||||
|
||||
with to_cmdline_implementation.filter_env_vars(
|
||||
'URL', 'FILE_PATH', 'FILE', 'FRAGMENT', 'URL_PATH',
|
||||
'URL', 'FILE_PATH', 'FILE', 'FRAGMENT', 'URL_PATH', 'NETLOC',
|
||||
EDITOR=shlex.join(get_editor()),
|
||||
SHELL=resolved_shell(get_options())[0]
|
||||
):
|
||||
@ -164,6 +164,7 @@ def actions_for_url_from_list(url: str, actions: Iterable[OpenAction]) -> Iterat
|
||||
return
|
||||
path = unquote(purl.path)
|
||||
up = purl.path
|
||||
netloc = unquote(purl.netloc) if purl.netloc else ''
|
||||
frag = ''
|
||||
if purl.query:
|
||||
up += f'?{purl.query}'
|
||||
@ -181,6 +182,7 @@ def actions_for_url_from_list(url: str, actions: Iterable[OpenAction]) -> Iterat
|
||||
'URL_PATH': up,
|
||||
'FILE': posixpath.basename(path),
|
||||
'FRAGMENT': frag,
|
||||
'NETLOC': netloc,
|
||||
}
|
||||
|
||||
def expand(x: Any) -> Any:
|
||||
@ -236,7 +238,7 @@ def default_open_actions() -> Tuple[OpenAction, ...]:
|
||||
# Open kitty HTML docs links
|
||||
protocol kitty+doc
|
||||
action show_kitty_doc $URL_PATH
|
||||
'''.splitlines()))
|
||||
'''.splitlines()))
|
||||
|
||||
|
||||
@run_once
|
||||
|
@ -1073,11 +1073,6 @@ def open_url(self, url: str, hyperlink_id: int, cwd: Optional[str] = None) -> No
|
||||
self.handle_remote_file(purl.netloc, unquote(purl.path))
|
||||
return
|
||||
url = urlunparse(purl._replace(netloc=''))
|
||||
if purl.fragment and purl.fragment.startswith('-'):
|
||||
# Dont allow fragments that startwith - as that can lead to arg
|
||||
# injection
|
||||
log_error('Ignoring fragment that starts with - in URL:', url)
|
||||
url = urlunparse(purl._replace(fragment=''))
|
||||
if opts.allow_hyperlinks & 0b10:
|
||||
from kittens.tui.operations import styled
|
||||
boss.choose(
|
||||
|
Loading…
Reference in New Issue
Block a user