[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
1 changed files with 6 additions and 2 deletions

View File

@ -24,8 +24,12 @@
{%- for answer in answers.values() -%} {%- for answer in answers.values() -%}
<div class="answer"> <div class="answer">
<span>{{ answer.answer }}</span> <span>{{ answer.answer }}</span>
{% if answer.url -%} {%- if answer.url -%}
<a href="{{ answer.url }}" class="answer-url">{{ urlparse(answer.url).hostname }}</a> <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 -%} {% endif -%}
</div> </div>
{%- endfor -%} {%- endfor -%}