From 949fb84ff41ff3ce7f2c2e77cd1a98196abb46bc Mon Sep 17 00:00:00 2001 From: Kamil Cukrowski Date: Tue, 13 Sep 2022 22:26:20 +0200 Subject: [PATCH] Implement clickable source links in ui --- admin/ui/route.go | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/admin/ui/route.go b/admin/ui/route.go index 3faf6b64b..a3d58a81a 100644 --- a/admin/ui/route.go +++ b/admin/ui/route.go @@ -99,7 +99,16 @@ $(function(){ $tr.append($('').text(i+1)); $tr.append($('').text(r.service)); - $tr.append($('').text(r.src)); + // If the link redirects to http or https destination. + const rx = /^https?:\/\/[^\/]+\/?$/.exec(r.dst) + if (rx != null) { + // If the src is missing hostname, take the hostname from current url. + const hrefsrc = "http://" + (r.src.startsWith("/") ? window.location.hostname : "") + r.src + // Create a link with href for source. + $tr.append($('').append($('').attr('href', hrefsrc).text(r.src))); + } else { + $tr.append($('').text(r.src)); + } $tr.append($('').append($('').attr('href', r.dst).text(r.dst))); $tr.append($('').text(r.opts)); $tr.append($('').text((r.weight * 100).toFixed(2) + '%'));