Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove "/" before endpoints & tags #734

Merged
merged 5 commits into from
Apr 27, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
7 changes: 4 additions & 3 deletions app/filter.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ def clean_css(css: str, page_url: str) -> str:
continue
css = css.replace(
url,
f'/element?type=image/png&url={abs_url}'
f'{Endpoint.element}?type=image/png&url={abs_url}'
)

return css
Expand Down Expand Up @@ -466,7 +466,8 @@ def update_link(self, link: Tag) -> None:
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?'):
elif (href.startswith('/?') or href.startswith('/search?') or
href.startswith('/imgres?')):
# make sure that tags can be clicked as relative URLs
link['href'] = href[1:]
elif href.startswith('/intl/'):
Expand Down Expand Up @@ -528,7 +529,7 @@ def view_image(self, soup) -> BeautifulSoup:
continue

img_url = urlparse.unquote(urls[0].replace(
f'/{Endpoint.imgres}?imgurl=', ''))
f'{Endpoint.imgres}?imgurl=', ''))

try:
# Try to strip out only the necessary part of the web page link
Expand Down
4 changes: 2 additions & 2 deletions app/utils/results.py
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ def append_nojs(result: BeautifulSoup) -> None:

"""
nojs_link = BeautifulSoup(features='html.parser').new_tag('a')
nojs_link['href'] = f'/{Endpoint.window}?nojs=1&location=' + result['href']
nojs_link['href'] = f'{Endpoint.window}?nojs=1&location=' + result['href']
nojs_link.string = ' NoJS Link'
result.append(nojs_link)

Expand All @@ -206,7 +206,7 @@ def append_anon_view(result: BeautifulSoup, config: Config) -> None:
av_link = BeautifulSoup(features='html.parser').new_tag('a')
nojs = 'nojs=1' if config.nojs else 'nojs=0'
location = f'location={result["href"]}'
av_link['href'] = f'/{Endpoint.window}?{nojs}&{location}'
av_link['href'] = f'{Endpoint.window}?{nojs}&{location}'
translation = current_app.config['TRANSLATIONS'][
config.get_localization_lang()
]
Expand Down