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

closes odoo/odoo#33858

Signed-off-by: Jérémy Kersten (jke) <jke@openerp.com>
This commit is contained in:
Bohdan Lisnenko
2019-06-04 10:53:17 +00:00
parent 77da958be6
commit bd3a788479
+5 -6
View File
@@ -44,7 +44,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,
@@ -62,13 +62,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)
return slug_str[:max_length]
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
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: