Comparing version 0.2.2 to 0.3.0
(function() { | ||
var char_map, removelist, slug, symbols, word; | ||
symbols = require('unicode/category/So'); | ||
removelist = ['sign', 'cross', 'of', 'symbol', 'staff']; | ||
removelist = (function() { | ||
@@ -14,2 +17,3 @@ var _i, _len, _results; | ||
})(); | ||
char_map = { | ||
@@ -156,8 +160,2 @@ 'À': 'A', | ||
'İ': 'I', | ||
'ç': 'c', | ||
'Ç': 'C', | ||
'ü': 'u', | ||
'Ü': 'U', | ||
'ö': 'o', | ||
'Ö': 'O', | ||
'ğ': 'g', | ||
@@ -262,3 +260,2 @@ 'Ğ': 'G', | ||
'ń': 'n', | ||
'ó': 'o', | ||
'ś': 's', | ||
@@ -276,3 +273,2 @@ 'ź': 'z', | ||
'ā': 'a', | ||
'č': 'c', | ||
'ē': 'e', | ||
@@ -284,7 +280,4 @@ 'ģ': 'g', | ||
'ņ': 'n', | ||
'š': 's', | ||
'ū': 'u', | ||
'ž': 'z', | ||
'Ā': 'A', | ||
'Č': 'C', | ||
'Ē': 'E', | ||
@@ -296,5 +289,3 @@ 'Ģ': 'G', | ||
'Ņ': 'N', | ||
'Š': 'S', | ||
'Ū': 'u', | ||
'Ž': 'Z', | ||
'€': 'euro', | ||
@@ -357,9 +348,25 @@ '₢': 'cruzeiro', | ||
}; | ||
module.exports = slug = function(string, replacement) { | ||
var char, code, i, result, unicode, word, _i, _len, _len2; | ||
if (replacement == null) { | ||
replacement = '-'; | ||
module.exports = slug = function(string, opts) { | ||
var char, code, i, result, unicode, _i, _j, _len, _len1; | ||
if (opts == null) { | ||
opts = {}; | ||
} | ||
if ('string' === typeof opts) { | ||
opts = { | ||
replacement: opts | ||
}; | ||
} else if ('boolean' === typeof opts) { | ||
opts = { | ||
lowerCase: opts | ||
}; | ||
} | ||
if (opts.replacement == null) { | ||
opts.replacement = '-'; | ||
} | ||
result = ""; | ||
for (i = 0, _len = string.length; i < _len; i++) { | ||
if (opts.lowerCase) { | ||
string = string.toLowerCase(); | ||
} | ||
for (i = _i = 0, _len = string.length; _i < _len; i = ++_i) { | ||
char = string[i]; | ||
@@ -374,4 +381,4 @@ code = string.charCodeAt(i); | ||
char = unicode.name.toLowerCase(); | ||
for (_i = 0, _len2 = removelist.length; _i < _len2; _i++) { | ||
word = removelist[_i]; | ||
for (_j = 0, _len1 = removelist.length; _j < _len1; _j++) { | ||
word = removelist[_j]; | ||
char = char.replace(word, ''); | ||
@@ -385,5 +392,6 @@ } | ||
result = result.replace(/^\s+|\s+$/g, ''); | ||
result = result.replace(/[-\s]+/g, replacement); | ||
return result.replace("" + replacement + "$", ''); | ||
result = result.replace(/[-\s]+/g, opts.replacement); | ||
return result.replace("" + opts.replacement + "$", ''); | ||
}; | ||
}).call(this); |
{ "name": "slug" | ||
, "description": "slugifies even utf-8 chars!" | ||
, "version": "0.2.2" | ||
, "version": "0.3.0" | ||
, "homepage": "https://github.com/dodo/node-slug" | ||
@@ -5,0 +5,0 @@ , "author": "dodo (https://github.com/dodo)" |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Native code
Supply chain riskContains native code (e.g., compiled binaries or shared libraries). Including native code can obscure malicious behavior.
Found 1 instance in 1 package
384
0
15253
8