Comparing version 0.9.0 to 0.9.1
{ | ||
"name": "slug", | ||
"version": "0.9.0", | ||
"version": "0.9.1", | ||
"homepage": "https://github.com/dodo/node-slug", | ||
@@ -5,0 +5,0 @@ "authors": [ |
{ "name": "slug" | ||
, "description": "slugifies even utf-8 chars!" | ||
, "version": "0.9.0" | ||
, "version": "0.9.1" | ||
, "homepage": "https://github.com/dodo/node-slug" | ||
@@ -5,0 +5,0 @@ , "author": "dodo (https://github.com/dodo)" |
28
slug.js
@@ -19,13 +19,19 @@ (function (root) { | ||
var defaults = slug.defaults.modes[opts.mode]; | ||
['replacement','multicharmap','charmap','remove','lower'].forEach(function (key) { | ||
var keys = ['replacement','multicharmap','charmap','remove','lower']; | ||
for (var key, i = 0, l = keys.length; i < l; i++) { key = keys[i]; | ||
opts[key] = (key in opts) ? opts[key] : defaults[key]; | ||
}); | ||
} | ||
if ('undefined' === typeof opts.symbols) | ||
opts.symbols = defaults.symbols; | ||
var lengths = []; | ||
Object.keys(opts.multicharmap).forEach(function (key) { | ||
for (var key in opts.multicharmap) { | ||
if (!opts.multicharmap.hasOwnProperty(key)) | ||
continue; | ||
var len = key.length; | ||
if (lengths.indexOf(len) === -1) | ||
lengths.push(len); | ||
}); | ||
} | ||
var code, unicode, result = ""; | ||
@@ -186,5 +192,8 @@ for (var char, i = 0, l = string.length; i < l; i++) { char = string[i]; | ||
// dont load symbols table in the browser | ||
Object.keys(slug.defaults.modes).forEach(function (key) { | ||
for (var key in slug.defaults.modes) { | ||
if (!slug.defaults.modes.hasOwnProperty(key)) | ||
continue; | ||
slug.defaults.modes[key].symbols = false; | ||
}); | ||
} | ||
define([], function () {return slug}); | ||
@@ -196,5 +205,8 @@ } else if (typeof module !== 'undefined' && module.exports) { // CommonJS | ||
// dont load symbols table in the browser | ||
Object.keys(slug.defaults.modes).forEach(function (key) { | ||
for (var key in slug.defaults.modes) { | ||
if (!slug.defaults.modes.hasOwnProperty(key)) | ||
continue; | ||
slug.defaults.modes[key].symbols = false; | ||
}); | ||
} | ||
root.slug = slug; | ||
@@ -201,0 +213,0 @@ } |
36928
434