mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-02-17 23:44:39 -05:00
bug caused by unidecode's bug
close #1986 - remove URL reserved chars after unidecode, because unidecode will produce some URL reserved chars.
This commit is contained in:
parent
0322676657
commit
1d1caada6b
1 changed files with 7 additions and 3 deletions
|
@ -213,8 +213,13 @@ ghostBookshelf.Model = ghostBookshelf.Model.extend({
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
slug = base.trim();
|
||||||
|
|
||||||
|
// Remove non ascii characters
|
||||||
|
slug = unidecode(slug);
|
||||||
|
|
||||||
// Remove URL reserved chars: `:/?#[]@!$&'()*+,;=` as well as `\%<>|^~£"`
|
// Remove URL reserved chars: `:/?#[]@!$&'()*+,;=` as well as `\%<>|^~£"`
|
||||||
slug = base.trim().replace(/[:\/\?#\[\]@!$&'()*+,;=\\%<>\|\^~£"]/g, '')
|
slug = slug.replace(/[:\/\?#\[\]@!$&'()*+,;=\\%<>\|\^~£"]/g, '')
|
||||||
// Replace dots and spaces with a dash
|
// Replace dots and spaces with a dash
|
||||||
.replace(/(\s|\.)/g, '-')
|
.replace(/(\s|\.)/g, '-')
|
||||||
// Convert 2 or more dashes into a single dash
|
// Convert 2 or more dashes into a single dash
|
||||||
|
@ -224,8 +229,7 @@ ghostBookshelf.Model = ghostBookshelf.Model.extend({
|
||||||
|
|
||||||
// Remove trailing hyphen
|
// Remove trailing hyphen
|
||||||
slug = slug.charAt(slug.length - 1) === '-' ? slug.substr(0, slug.length - 1) : slug;
|
slug = slug.charAt(slug.length - 1) === '-' ? slug.substr(0, slug.length - 1) : slug;
|
||||||
// Remove non ascii characters
|
|
||||||
slug = unidecode(slug);
|
|
||||||
// Check the filtered slug doesn't match any of the reserved keywords
|
// Check the filtered slug doesn't match any of the reserved keywords
|
||||||
slug = /^(ghost|ghost\-admin|admin|wp\-admin|wp\-login|dashboard|logout|login|signin|signup|signout|register|archive|archives|category|categories|tag|tags|page|pages|post|posts|user|users|rss)$/g
|
slug = /^(ghost|ghost\-admin|admin|wp\-admin|wp\-login|dashboard|logout|login|signin|signup|signout|register|archive|archives|category|categories|tag|tags|page|pages|post|posts|user|users|rss)$/g
|
||||||
.test(slug) ? slug + '-post' : slug;
|
.test(slug) ? slug + '-post' : slug;
|
||||||
|
|
Loading…
Add table
Reference in a new issue