Comparing version 1.1.0 to 2.0.0
{ | ||
"name": "slug", | ||
"description": "slugifies even utf-8 chars!", | ||
"version": "1.1.0", | ||
"version": "2.0.0", | ||
"homepage": "https://github.com/Trott/node-slug", | ||
@@ -22,3 +22,3 @@ "author": "dodo (https://github.com/dodo)", | ||
"scripts": { | ||
"test": "./node_modules/.bin/mocha ./test/*.test.* --require should --reporter spec --colors --compilers coffee:coffee-script/register" | ||
"test": "eslint . && mocha ./test/*.test.* --require should --reporter spec --colors" | ||
}, | ||
@@ -29,5 +29,5 @@ "dependencies": { | ||
"devDependencies": { | ||
"coffee-script": "~1.7.1", | ||
"mocha": "^5.2.0", | ||
"should": "~3.1.2" | ||
"eslint": "^6.8.0", | ||
"mocha": "^6.2.1", | ||
"should": "~13.2.3" | ||
}, | ||
@@ -34,0 +34,0 @@ "bin": { |
@@ -10,3 +10,3 @@ # [slug](https://github.com/Trott/node-slug) | ||
- No dependencies (except the unicode table) | ||
- Not in coffee-script (except the tests lol) | ||
- Not in coffee-script | ||
- Coerces foreign symbols to their english equivalent | ||
@@ -31,3 +31,3 @@ - Works in browser (window.slug) and AMD/CommonJS-flavoured module loaders (except the unicode symbols unless you use browserify but who wants to download a ~2mb js file, right?) | ||
print(slug('i ♥ unicode', '_')) // If you prefer something else then `-` as seperator | ||
print(slug('i ♥ unicode', '_')) // If you prefer something else than `-` as separator | ||
// > i_love_unicode | ||
@@ -34,0 +34,0 @@ |
16
slug.js
@@ -20,3 +20,3 @@ (function (root) { | ||
var keys = ['replacement','multicharmap','charmap','remove','lower']; | ||
for (var key, i = 0, l = keys.length; i < l; i++) { key = keys[i]; | ||
for (let key, i = 0, l = keys.length; i < l; i++) { key = keys[i]; | ||
opts[key] = (key in opts) ? opts[key] : defaults[key]; | ||
@@ -28,3 +28,3 @@ } | ||
var lengths = []; | ||
for (var key in opts.multicharmap) { | ||
for (let key in opts.multicharmap) { | ||
if (!opts.multicharmap.hasOwnProperty(key)) | ||
@@ -39,3 +39,3 @@ continue; | ||
var code, unicode, result = ""; | ||
for (var char, i = 0, l = string.length; i < l; i++) { char = string[i]; | ||
for (let char, i = 0, l = string.length; i < l; i++) { char = string[i]; | ||
if (!lengths.some(function (len) { | ||
@@ -63,3 +63,3 @@ var str = string.substr(i, len); | ||
} | ||
char = char.replace(/[^\w\s\-\.\_~]/g, ''); // allowed | ||
char = char.replace(/[^\w\s\-._~]/g, ''); // allowed | ||
if (opts.remove) char = char.replace(opts.remove, ''); // add flavour | ||
@@ -74,3 +74,3 @@ result += char; | ||
return result; | ||
}; | ||
} | ||
@@ -142,2 +142,4 @@ slug.defaults = { | ||
'ن': 'n', 'ه': 'h', 'و': 'o', 'ي': 'y', | ||
// farsi | ||
'آ': 'a', 'ا': 'a', 'پ': 'p', 'ژ': 'zh','گ': 'g','چ': 'ch','ک': 'k', 'ی': 'i', | ||
// lithuanian | ||
@@ -202,3 +204,3 @@ 'ė':'e', 'į':'i', 'ų':'u', 'Ė': 'E', 'Į': 'I', 'Ų':'U', | ||
// dont load symbols table in the browser | ||
for (var key in slug.defaults.modes) { | ||
for (let key in slug.defaults.modes) { | ||
if (!slug.defaults.modes.hasOwnProperty(key)) | ||
@@ -215,3 +217,3 @@ continue; | ||
// dont load symbols table in the browser | ||
for (var key in slug.defaults.modes) { | ||
for (let key in slug.defaults.modes) { | ||
if (!slug.defaults.modes.hasOwnProperty(key)) | ||
@@ -218,0 +220,0 @@ continue; |
30495
9
537