Skip to content

Commit 55bb579

Browse files
ZxMYSaoen
authored andcommitted
[AIRFLOW-5597] Linkify urls in task instance log (apache#6265)
1 parent 68b8ec5 commit 55bb579

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

airflow/www/templates/airflow/ti_log.html

+10-2
Original file line numberDiff line numberDiff line change
@@ -121,10 +121,18 @@ <h4>{{ title }}</h4>
121121
if (res.message) {
122122
// Auto scroll window to the end if current window location is near the end.
123123
if(auto_tailing && checkAutoTailingCondition()) {
124-
var should_scroll = true
124+
var should_scroll = true;
125125
}
126126
// The message may contain HTML, so either have to escape it or write it as text.
127-
document.getElementById(`try-${try_number}`).textContent += res.message + "\n";
127+
var escaped_message = escapeHtml(res.message);
128+
129+
// Detect urls
130+
var url_regex = /http(s)?:\/\/[\w\.\-]+(\.?:[\w\.\-]+)*([\/?#][\w\-\._~:/?#[\]@!\$&'\(\)\*\+,;=\.%]+)?/g;
131+
var linkified_message = escaped_message.replace(url_regex, function(url) {
132+
return "<a href=\"" + url + "\" target=\"_blank\">" + url + "</a>";
133+
});
134+
135+
document.getElementById(`try-${try_number}`).innerHTML += linkified_message + "<br/>";
128136
// Auto scroll window to the end if current window location is near the end.
129137
if(should_scroll) {
130138
scrollBottom();

0 commit comments

Comments
 (0)