Skip to content

Commit

Permalink
Improve the max-length criteria (#19)
Browse files Browse the repository at this point in the history
  • Loading branch information
Pchelolo authored and Marko Obrovac committed Aug 10, 2016
1 parent b0241a3 commit d55858a
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 3 deletions.
2 changes: 1 addition & 1 deletion lib/index.js
Expand Up @@ -279,7 +279,7 @@ function _checkTalkNamespace(title, siteInfo) {
}

function _checkMaxLength(title, namespace) {
var maxLength = !namespace.isSpecial() ? 255 : 512;
var maxLength = namespace.isSpecial() ? 512 : 256;
if (title.length > maxLength) {
throw new utils.TitleError({
type: 'title-invalid-too-long',
Expand Down
2 changes: 1 addition & 1 deletion package.json
@@ -1,6 +1,6 @@
{
"name": "mediawiki-title",
"version": "0.5.4",
"version": "0.5.5",
"description": "Title normalization library for mediawiki",
"main": "lib/index.js",
"scripts": {
Expand Down
3 changes: 2 additions & 1 deletion test/index.js
Expand Up @@ -74,7 +74,7 @@ function doTest(formatversion) {
['A ~~~~ Signature', 'title-invalid-magic-tilde'],
['A ~~~~~ Timestamp', 'title-invalid-magic-tilde'],
// Length
[ new Array(257).join('x'), 'title-invalid-too-long' ],
[ new Array(258).join('x'), 'title-invalid-too-long' ],
[ 'Special:' + new Array(514).join('x'), 'title-invalid-too-long' ],
// Namespace prefix without actual title
['Talk:', 'title-invalid-empty'],
Expand Down Expand Up @@ -124,6 +124,7 @@ function doTest(formatversion) {
// Special pages can have longer titles
[ 'Special:' + new Array(500).join('x') ],
[ new Array(252).join('x') ],
[ new Array(257).join('x') ],
[ '-' ],
[ 'aũ' ],
[ '"Believing_Women"_in_Islam._Unreading_Patriarchal_Interpretations_of_the_Qur\\\'ān']
Expand Down

0 comments on commit d55858a

Please sign in to comment.