mirror of
https://github.com/quine-global/hyper.git
synced 2026-01-13 04:28:41 -09:00
fix url handling in zsh (#50)
This commit is contained in:
parent
eb7f8feb6d
commit
951044c17e
1 changed files with 15 additions and 2 deletions
17
app/term.js
17
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 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 {
|
export default class Term extends Component {
|
||||||
|
|
||||||
|
|
@ -110,9 +112,19 @@ export default class Term extends Component {
|
||||||
}
|
}
|
||||||
|
|
||||||
write (data) {
|
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) {
|
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
|
// extract the domain portion from the url
|
||||||
const domain = url.split('/')[0];
|
const domain = url.split('/')[0];
|
||||||
if (domainRegex.test(domain)) {
|
if (domainRegex.test(domain)) {
|
||||||
|
|
@ -120,6 +132,7 @@ export default class Term extends Component {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
this.term.io.print(data);
|
this.term.io.print(data);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue