[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> closes odoo/odoo#34363 Signed-off-by: Jérémy Kersten (jke) <jke@openerp.com>
This commit is contained in:
committed by
Jeremy Kersten
parent
3d27337f6d
commit
7742887e96
@@ -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)
|
||||
|
||||
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:
|
||||
|
||||
Reference in New Issue
Block a user