Skip to content
This repository has been archived by the owner on Aug 26, 2022. It is now read-only.

Commit

Permalink
Merge 45eb565 into 95a6480
Browse files Browse the repository at this point in the history
  • Loading branch information
darkwing committed Jun 19, 2014
2 parents 95a6480 + 45eb565 commit 17abf65
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 9 deletions.
3 changes: 1 addition & 2 deletions media/js/wiki-edit.js
Expand Up @@ -140,8 +140,7 @@
});

var s = values.join(' ');

s = $.slugifyString(s);
s = $.slugifyString(s, false, true);

// Trim to first num_chars chars
s = s.substring(0, maxLength);
Expand Down
2 changes: 1 addition & 1 deletion media/js/wiki-move.js
Expand Up @@ -62,6 +62,6 @@

// Help on the client side for validating slugs to be moved
$moveSlug.on('change keyup focus blur', function() {
this.value = $.slugifyString(this.value.replace(moveRegex, ''), true);
this.value = $.slugifyString(this.value.replace(moveRegex, ''), true, true);
});
})(jQuery);
18 changes: 12 additions & 6 deletions media/redesign/js/wiki.js
Expand Up @@ -413,14 +413,20 @@
return nvpair;
},
// Used within the wiki new/move pages
slugifyString: function(str, allowSlash) {
slugifyString: function(str, allowSlash, allowMultipleUnderscores) {
var regex = new RegExp('[\?\&\"\'\#\*\$' + (allowSlash ? '' : '\/') + ' +?]', 'g');

// Remove anything from the slug that could cause big problems
return str.replace(regex, '_')
// "$" is used for verb delimiter in URLs
.replace(/\$/g, '')
// Don't allow "_____" mess
.replace(/\_+/g, '_');
var result = str.replace(regex, '_')
// "$" is used for verb delimiter in URLs
.replace(/\$/g, '');

// Don't allow "_____" mess
if(!allowMultipleUnderscores) {
result = result.replace(/\_+/g, '_');
}

return result;
}
});

Expand Down

0 comments on commit 17abf65

Please sign in to comment.