Remove the length argument to URLify

The URLify function supplied by django does not need a length argument in order to work. The problem with supplying the length argument is that when you have Unicode characters that are translated to two characters in the slug version, the resulting slug will be missing one character for each such double character.

Example:
Æ or æ is translated as ae when slugified.
A call to URLify would then be: URLify("kjaftæði", 8) which would result in the slug "kjaftaed", since the slug is 9 characters in length due to æ being expanded to two characters. URLify("kjaftæði") works fine and returns "kjaftaedi".
This commit is contained in:
Sævar Öfjörð Magnússon 2015-10-19 15:57:16 +00:00
parent 3b882dd1e9
commit 31358535b1

View file

@ -296,7 +296,7 @@ function InlinePanel(opts) {
function cleanForSlug(val, useURLify) {
if (URLify != undefined && useURLify !== false) { // Check to be sure that URLify function exists, and that we want to use it.
return URLify(val, val.length);
return URLify(val);
} else { // If not just do the "replace"
return val.replace(/\s/g, '-').replace(/[^A-Za-z0-9\-\_]/g, '').toLowerCase();
}