larvitslugify
Advanced tools
Comparing version 0.11.1 to 0.11.2
11
index.js
@@ -31,2 +31,13 @@ 'use strict'; | ||
// Shorthand for saving characters | ||
if (options.save) { | ||
if ( ! Array.isArray(options.save)) { | ||
options.save = [options.save]; | ||
} | ||
for (let i = 0; options.save[i] !== undefined; i ++) { | ||
charmap[options.save[i]] = options.save[i]; | ||
} | ||
} | ||
// Set whitespace characters that is no in the charmap | ||
@@ -33,0 +44,0 @@ // We do this since we'd like to handle explicit whitecharacters separately |
{ | ||
"name": "larvitslugify", | ||
"description": "Slugify string to make them url safe and more", | ||
"version": "0.11.1", | ||
"version": "0.11.2", | ||
"homepage": "https://github.com/larvit/larvitslugify", | ||
@@ -6,0 +6,0 @@ "author": "Lilleman <lilleman@larvit.se>", |
@@ -51,2 +51,3 @@ [](https://travis-ci.org/larvit/larvitslugify) | ||
'whitespaces': = [' ', '\t', '\xa0'] // A list of characters identified as whitespaces | ||
'save': = undefined // Adds a character to the charmap to "save" from being changed or removed. Takes a string of one character or an array of single caracter strings | ||
@@ -53,0 +54,0 @@ //'wordLimit': 5 // Limits the amount of words to this number (Currently not supported) |
@@ -383,2 +383,18 @@ 'use strict'; | ||
it('should save some character method 2', function (done) { | ||
const text = 'It\'s Your Jöurney We Guide You Through!', | ||
expected = 'Its-Your-Jöurney-We-Guide-You-Through'; | ||
assert.strictEqual(slug(text, {'save': 'ö'}), expected); | ||
done(); | ||
}); | ||
it('should save some character method 2 multiple characters', function (done) { | ||
const text = 'It\'s Your Jöurney We Guide You Through!', | ||
expected = 'Its-Your-Jöurney-We-Guide-You-Through!'; | ||
assert.strictEqual(slug(text, {'save': ['ö', '!']}), expected); | ||
done(); | ||
}); | ||
it('should save the dot character', function (done) { | ||
@@ -385,0 +401,0 @@ const text = 'It\'s Your Jöurney We Guide You Through.', |
27814
567
56