Skip to content

Commit 3c0abdf

Browse files
authored
Merge pull request #895 from mattrose/865-file-links-not-clickable-if-the-root-dir-has-a-underscore
Properly parse file:/// URIs
2 parents 51e3bd2 + 4e6e293 commit 3c0abdf

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

terminatorlib/terminal.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -300,6 +300,7 @@ def load_plugins(self, force = False):
300300
registry.load_plugins(force)
301301

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

330331
lboundry = "\\b"
331332
rboundry = "\\b"
332333

334+
re = (lboundry + "file:/" + "//?(:[0-9]+)?(" + urlpath + ")" +
335+
rboundry + "/?")
336+
self._add_regex('file', re)
337+
333338
re = (lboundry + schemes +
334339
"//(" + user + "@)?[" + hostchars +".]+(:[0-9]+)?(" +
335340
urlpath + ")?" + rboundry + "/?")
336341
self._add_regex('full_uri', re)
337342

338-
if self.matches['full_uri'] == -1:
343+
if self.matches['full_uri'] == -1 or self.matches['file'] == -1:
339344
err ('Terminal::update_url_matches: Failed adding URL matches')
340345
else:
341346
re = (lboundry +

0 commit comments

Comments
 (0)