Skip to content

Commit

Permalink
Merge pull request #895 from mattrose/865-file-links-not-clickable-if…
Browse files Browse the repository at this point in the history
…-the-root-dir-has-a-underscore

Properly parse file:/// URIs
  • Loading branch information
mattrose authored Mar 14, 2024
2 parents 51e3bd2 + 4e6e293 commit 3c0abdf
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions terminatorlib/terminal.py
Original file line number Diff line number Diff line change
Expand Up @@ -300,6 +300,7 @@ def load_plugins(self, force = False):
registry.load_plugins(force)

def _add_regex(self, name, re):
dbg(f"adding regex: {re}")
match = -1
if regex.FLAGS_PCRE2:
try:
Expand All @@ -323,19 +324,23 @@ def update_url_matches(self):
passchars = "-A-Za-z0-9,?;.:/!%$^*&~\"#'"
hostchars = r"-A-Za-z0-9:\[\]"
pathchars = "-A-Za-z0-9_$.+!*(),;:@&=?/~#%'"
schemes = "(news:|telnet:|nntp:|file:/|https?:|ftps?:|webcal:|ssh:)"
schemes = "(news:|telnet:|nntp:|https?:|ftps?:|webcal:|ssh:)"
user = "[" + userchars + "]+(:[" + passchars + "]+)?"
urlpath = "/[" + pathchars + "]*[^]'.}>) \t\r\n,\\\"]"

lboundry = "\\b"
rboundry = "\\b"

re = (lboundry + "file:/" + "//?(:[0-9]+)?(" + urlpath + ")" +
rboundry + "/?")
self._add_regex('file', re)

re = (lboundry + schemes +
"//(" + user + "@)?[" + hostchars +".]+(:[0-9]+)?(" +
urlpath + ")?" + rboundry + "/?")
self._add_regex('full_uri', re)

if self.matches['full_uri'] == -1:
if self.matches['full_uri'] == -1 or self.matches['file'] == -1:
err ('Terminal::update_url_matches: Failed adding URL matches')
else:
re = (lboundry +
Expand Down

0 comments on commit 3c0abdf

Please sign in to comment.