From 951044c17e2208ff58cdc34bb3affa034c439155 Mon Sep 17 00:00:00 2001 From: Guillermo Rauch Date: Tue, 5 Jul 2016 13:14:30 -0700 Subject: [PATCH] fix url handling in zsh (#50) --- app/term.js | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/app/term.js b/app/term.js index 423f36ab..07506bd2 100644 --- a/app/term.js +++ b/app/term.js @@ -46,6 +46,8 @@ hterm.Keyboard.prototype.onKeyPress_ = function (e) { }; const domainRegex = /\b((?=[a-z0-9-]{1,63}\.)(xn--)?[a-z0-9]+(-[a-z0-9]+)*\.)+[a-z]{2,63}\b/; +const bashRegex = /bash: ((https?:\/\/)|(\/\/))?(.*): ((command not found)|(No such file or directory))/; +const zshRegex = /zsh: ((command not found)|(no such file or directory)): ((https?:\/\/)|(\/\/))?([^\n]+)/; export default class Term extends Component { @@ -110,9 +112,19 @@ export default class Term extends Component { } write (data) { - const match = data.match(/bash: ((https?:\/\/)|(\/\/))?(.*): ((command not found)|(No such file or directory))/); + let match = data.match(bashRegex); + let url; + if (match) { - const url = match[4]; + url = match[4]; + } else { + match = data.match(zshRegex); + if (match) { + url = match[7]; + } + } + + if (url) { // extract the domain portion from the url const domain = url.split('/')[0]; if (domainRegex.test(domain)) { @@ -120,6 +132,7 @@ export default class Term extends Component { return; } } + this.term.io.print(data); }