Skip to content

Commit

Permalink
[AIRFLOW-5597] Linkify urls in task instance log (apache#6265)
Browse files Browse the repository at this point in the history
  • Loading branch information
ZxMYS authored and aoen committed Oct 8, 2019
1 parent 68b8ec5 commit 55bb579
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions airflow/www/templates/airflow/ti_log.html
Original file line number Diff line number Diff line change
Expand Up @@ -121,10 +121,18 @@ <h4>{{ title }}</h4>
if (res.message) {
// Auto scroll window to the end if current window location is near the end.
if(auto_tailing && checkAutoTailingCondition()) {
var should_scroll = true
var should_scroll = true;
}
// The message may contain HTML, so either have to escape it or write it as text.
document.getElementById(`try-${try_number}`).textContent += res.message + "\n";
var escaped_message = escapeHtml(res.message);

// Detect urls
var url_regex = /http(s)?:\/\/[\w\.\-]+(\.?:[\w\.\-]+)*([\/?#][\w\-\._~:/?#[\]@!\$&'\(\)\*\+,;=\.%]+)?/g;
var linkified_message = escaped_message.replace(url_regex, function(url) {
return "<a href=\"" + url + "\" target=\"_blank\">" + url + "</a>";
});

document.getElementById(`try-${try_number}`).innerHTML += linkified_message + "<br/>";
// Auto scroll window to the end if current window location is near the end.
if(should_scroll) {
scrollBottom();
Expand Down

0 comments on commit 55bb579

Please sign in to comment.