[fix] respect user preferences to open links in new tab for short answers

Previously only result urls were set to open in new tab by default, this should
make the behaviour consistent.

Also adds the missing rel="noreferrer" to the anchor tag. Although this should
not be needed as long as the `referrer-policy: no-referrer` header is set, it's
always nice to play safer than to have to say sorry.  For example some reverse
proxy configurations might strip off unwhitelisted headers in which case it's
nice to have this set.
This commit is contained in:
Yaksh Bariya 2024-05-02 15:44:45 +05:30 committed by Markus Heiser
parent 78077126f2
commit d577817646

View file

@ -24,8 +24,12 @@
{%- for answer in answers.values() -%}
<div class="answer">
<span>{{ answer.answer }}</span>
{% if answer.url -%}
<a href="{{ answer.url }}" class="answer-url">{{ urlparse(answer.url).hostname }}</a>
{%- if answer.url -%}
<a href="{{ answer.url }}" class="answer-url"
{%- if results_on_new_tab %} target="_blank" rel="noopener noreferrer"
{%- else -%} rel="noreferrer"
{%- endif -%}
>{{ urlparse(answer.url).hostname }}</a>
{% endif -%}
</div>
{%- endfor -%}