qr_code fixes

use short_url on standalone QR code generation
filter out redundant arguments to further shorten the URL.  Current list to filter are the format, and the qr_code arguments
This commit is contained in:
caleb crome 2023-03-08 20:48:48 -08:00 committed by Florian Festi
parent 0b986eeb0c
commit 98a6538573
1 changed files with 8 additions and 3 deletions

View File

@ -90,11 +90,17 @@ def filter_url(url, non_default_args):
return ''
args = args.split('&')
new_args = []
args_to_ignore = ["qr_code", "format"]
for arg in args:
a, b = arg.split('=')
if a.strip() in args_to_ignore:
continue
if a in non_default_args:
new_args.append(arg)
return f"{base}?{'&'.join(new_args)}"
if len(new_args):
return f"{base}?{'&'.join(new_args)}"
else:
return f"{base}"
class ArgumentParserError(Exception): pass
@ -639,8 +645,7 @@ class BServer:
qr_format="png"
fn = (box.__class__.__name__)
start_response(status, http_headers)
url = re.sub(r"&render=[^&]*", "" ,self.getURL(environ))
qrcode = get_qrcode(url, qr_format)
qrcode = get_qrcode(box.metadata["url_short"], qr_format)
return (qrcode,)
if box.format != "svg" or render == "2":