Skip to content
Snippets Groups Projects
Commit 7742887e authored by Bohdan Lisnenko's avatar Bohdan Lisnenko Committed by Jeremy Kersten
Browse files

[FIX] http_routing: slugify_lib - max_length param should be int


closes odoo/odoo#33858

Signed-off-by: default avatarJérémy Kersten (jke) <jke@openerp.com>

closes odoo/odoo#34363

Signed-off-by: default avatarJérémy Kersten (jke) <jke@openerp.com>
parent 3d27337f
Branches
Tags
No related merge requests found
......@@ -43,7 +43,7 @@ def _guess_mimetype(ext=False, default='text/html'):
return ext is not False and exts.get(ext, default) or exts
def slugify_one(s, max_length=None):
def slugify_one(s, max_length=0):
""" Transform a string to a slug that can be used in a url path.
This method will first try to do the job with python-slugify if present.
Otherwise it will process string by stripping leading and ending spaces,
......@@ -61,13 +61,12 @@ def slugify_one(s, max_length=None):
except TypeError:
pass
uni = unicodedata.normalize('NFKD', s).encode('ascii', 'ignore').decode('ascii')
slug_str = re.sub('[\W_]', ' ', uni).strip().lower()
slug_str = re.sub('[-\s]+', '-', slug_str)
slug_str = re.sub(r'[\W_]', ' ', uni).strip().lower()
slug_str = re.sub(r'[-\s]+', '-', slug_str)
return slug_str[:max_length] if max_length > 0 else slug_str
return slug_str[:max_length]
def slugify(s, max_length=None, path=False):
def slugify(s, max_length=0, path=False):
if not path:
return slugify_one(s, max_length=max_length)
else:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment