Relativization of search results

This commit is contained in:
gmd85 2022-04-07 01:35:04 +02:00 committed by gdm85
parent 2fcfeacd44
commit f60e132d3c
2 changed files with 13 additions and 1 deletions

View File

@ -104,6 +104,8 @@ class Filter:
input_form = soup.find('form')
if input_form is not None:
input_form['method'] = 'GET' if self.config.get_only else 'POST'
# Use a relative URI for submissions
input_form['action'] = 'search'
# Ensure no extra scripts passed through
for script in soup('script'):
@ -394,6 +396,16 @@ class Filter:
if href.startswith(MAPS_URL):
# Maps links don't work if a site filter is applied
link['href'] = MAPS_URL + "?q=" + clean_query(q)
elif href.startswith('/?') or href.startswith('/search?'):
# make sure that tags can be clicked as relative URLs
link['href'] = href[1:]
elif href.startswith('/intl/'):
# do nothing, keep original URL for ToS
pass
elif href.startswith('/preferences'):
# there is no config specific URL, remove this
link.decompose()
return
else:
link['href'] = href

View File

@ -1,4 +1,4 @@
<form id="search-form" action="{{ url }}/search" method="post">
<form id="search-form" action="search" method="post">
<input
type="text"
name="q"