Don't leave falsey values out of dict_to_params, let caller do it.

Explicit is better than implicit and all that.
This commit is contained in:
voussoir 2020-03-28 17:15:58 -07:00
parent 0fdf08adf5
commit a00fb65758
2 changed files with 5 additions and 4 deletions

View file

@ -425,7 +425,9 @@ def get_search_core():
if offset > 0: if offset > 0:
prev_params = original_params.copy() prev_params = original_params.copy()
prev_params['offset'] = max(0, offset - limit) prev_offset = max(0, offset - limit)
if prev_offset > 0:
prev_params['offset'] = prev_offset
prev_params = helpers.dict_to_params(prev_params) prev_params = helpers.dict_to_params(prev_params)
prev_page_url = '/search' + prev_params prev_page_url = '/search' + prev_params
else: else:

View file

@ -7,9 +7,8 @@ def dict_to_params(d):
if not d: if not d:
return '' return ''
params = [f'{key}={value}' for (key, value) in d.items() if value] params = [f'{key}={value}' for (key, value) in d.items()]
params = '&'.join(params) params = '&'.join(params)
if params: params = '?' + params
params = '?' + params
return params return params