Skip to content
Browse files

Avoid same bug as previous one with allowed chars rule.

  • Loading branch information...
1 parent 3eb2712 commit 1fc7df7f40de47bb0a809b400dae57737cf91484 @jeremys committed Feb 1, 2012
Showing with 11 additions and 8 deletions.
  1. +8 −7 lib/uslug.js
  2. +3 −1 test/test.js
View
15 lib/uslug.js
@@ -26,14 +26,15 @@
// See: http://www.unicode.org/versions/Unicode6.0.0/ch12.pdf - Table 12-2
if (0x4E00 <= code && code <= 0x9FFF) {
rv.push(c);
- } else {
- if (allowedChars.indexOf(c) != -1) rv.push(c);
- var val = _unicodeCategory(code);
- if (val) {
- if (~'LN'.indexOf(val)) rv.push(c);
- if (~'Z'.indexOf(val)) rv.push(' ');
- }
+ continue;
}
+ if (allowedChars.indexOf(c) != -1) {
+ rv.push(c);
+ continue;
+ }
+ var val = _unicodeCategory(code);
+ if (val && ~'LN'.indexOf(val)) rv.push(c);
+ if (val && ~'Z'.indexOf(val)) rv.push(' ');
}
slug = rv.join('').replace(/^\s+|\s+$/g, '').replace(/\s+/g,' ');
if (!spaces) slug = slug.replace(/[\s\-]+/g,'-');
View
4 test/test.js
@@ -31,4 +31,6 @@ var tests = [
for (var t in tests) {
var test = tests[t];
uslug(test[0]).should.equal(test[1]);
-}
+}
+
+uslug('qbc,fe', { allowedChars: 'q' }).should.equal('qbcfe');

0 comments on commit 1fc7df7

Please sign in to comment.
Something went wrong with that request. Please try again.