speakingurl
Advanced tools
Comparing version 0.12.1 to 0.12.3
{ | ||
"name": "speakingurl", | ||
"version": "0.12.1", | ||
"version": "0.12.3", | ||
"description": "Generate of so called 'static' or 'Clean URL' or 'Pretty URL' or 'nice-looking URL' or 'Speaking URL' or 'user-friendly URL' or 'SEO-friendly URL' or 'slug' from a string.", | ||
@@ -12,6 +12,8 @@ "main": "speakingurl.min.js", | ||
}, | ||
"licenses": [{ | ||
"type": "BSD", | ||
"url": "https://raw.github.com/pid/speakingurl/master/LICENSE" | ||
}], | ||
"licenses": [ | ||
{ | ||
"type": "BSD", | ||
"url": "https://raw.github.com/pid/speakingurl/master/LICENSE" | ||
} | ||
], | ||
"ignore": [ | ||
@@ -18,0 +20,0 @@ "node_modules" |
@@ -1,16 +0,20 @@ | ||
# Changelog | ||
Changelog | ||
========= | ||
* v0.12.0 add support for Czech and Slovak | ||
* v0.11.0 add support for Vietnamese | ||
* v0.10.0 changes in greek transliteration mapping table | ||
* v0.9.1 add support for Dutch | ||
* v0.9.0 updated dev dependencies; because of dep. we are only compatible with node > 0.10.x | ||
* v0.8.4 last version compatible with node v0.8.x | ||
* v0.8.0 add feature to set 'lang' to true or false to deactivate symbol translation | ||
* v0.7.0 add titleCase feature #26 | ||
* v0.6.0 add symbol translation pt | ||
* v0.5.0 enhance custom replacement; Add support for "black-listed" words #20 - keep old behavior for single character replacement - add custom replacement for string to string|char|'' // '' ~= remove | ||
* v0.4.0 add support for Arabic | ||
* v0.3.0 add Indian Rupee and Pfennig to currency map | ||
* v0.2.21 fix #17; if symbol at the end of input string | ||
* v0.2.18 add amd-support | ||
- v0.12.3 switch to gulpjs | ||
- v0.12.2 corrupt gulpfile, not published to npm registry | ||
- v0.12.1 update devDep | ||
- v0.12.0 add support for Czech and Slovak | ||
- v0.11.0 add support for Vietnamese | ||
- v0.10.0 changes in greek transliteration mapping table | ||
- v0.9.1 add support for Dutch | ||
- v0.9.0 updated dev dependencies; because of dep. we are only compatible with node > 0.10.x | ||
- v0.8.4 last version compatible with node v0.8.x | ||
- v0.8.0 add feature to set 'lang' to true or false to deactivate symbol translation | ||
- v0.7.0 add titleCase feature #26 | ||
- v0.6.0 add symbol translation pt | ||
- v0.5.0 enhance custom replacement; Add support for "black-listed" words #20 - keep old behavior for single character replacement - add custom replacement for string to string|char|'' // '' ~= remove | ||
- v0.4.0 add support for Arabic | ||
- v0.3.0 add Indian Rupee and Pfennig to currency map | ||
- v0.2.21 fix #17; if symbol at the end of input string | ||
- v0.2.18 add amd-support |
@@ -5,3 +5,3 @@ { | ||
"description": "Generate of so called 'static' or 'Clean URL' or 'Pretty URL' or 'nice-looking URL' or 'Speaking URL' or 'user-friendly URL' or 'SEO-friendly URL' or 'slug' from a string.", | ||
"version": "0.12.1", | ||
"version": "0.12.3", | ||
"keywords": [ | ||
@@ -8,0 +8,0 @@ "slug", |
@@ -1,2 +0,2 @@ | ||
(function() { | ||
(function () { | ||
'use strict'; | ||
@@ -15,4 +15,3 @@ | ||
var titleCase = (typeof opts === 'object' && opts.titleCase) ? opts.titleCase : false; | ||
var customReplacements = (typeof opts === 'object' && typeof opts.custom === 'object' && opts.custom) ? | ||
opts.custom : {}; | ||
var customReplacements = (typeof opts === 'object' && typeof opts.custom === 'object' && opts.custom) ? opts.custom : {}; | ||
var separator = (typeof opts === 'object' && opts.separator) || '-'; | ||
@@ -23,6 +22,4 @@ var truncate = (typeof opts === 'object' && +opts.truncate > 1 && opts.truncate) || false; | ||
var markFlag = (typeof opts === 'object' && opts.mark) || false; | ||
var symbol = (typeof opts === 'object' && opts.lang && symbolMap[opts.lang]) ? symbolMap[opts.lang] : | ||
(typeof opts === 'object' && (opts.lang === false || opts.lang === true) ? {} : symbolMap.en); | ||
var langChar = (typeof opts === 'object' && opts.lang && langCharMap[opts.lang]) ? langCharMap[opts.lang] : | ||
(typeof opts === 'object' && (opts.lang === false || opts.lang === true) ? {} : langCharMap.en); | ||
var symbol = (typeof opts === 'object' && opts.lang && symbolMap[opts.lang]) ? symbolMap[opts.lang] : (typeof opts === 'object' && (opts.lang === false || opts.lang === true) ? {} : symbolMap.en); | ||
var langChar = (typeof opts === 'object' && opts.lang && langCharMap[opts.lang]) ? langCharMap[opts.lang] : (typeof opts === 'object' && (opts.lang === false || opts.lang === true) ? {} : langCharMap.en); | ||
var uricChars = [';', '?', ':', '@', '&', '=', '+', '$', ',', '/']; | ||
@@ -42,3 +39,3 @@ var uricNoSlashChars = [';', '?', ':', '@', '&', '=', '+', '$', ',']; | ||
// custom config is an Array, rewrite to object format | ||
titleCase.forEach(function(v) { | ||
titleCase.forEach(function (v) { | ||
customReplacements[v + ""] = v + ""; | ||
@@ -70,3 +67,3 @@ }); | ||
// custom replacements | ||
Object.keys(customReplacements).forEach(function(v) { | ||
Object.keys(customReplacements).forEach(function (v) { | ||
@@ -86,6 +83,5 @@ var r; | ||
input = input.replace(/(\w)(\S*)/g, function(_, i, r) { | ||
input = input.replace(/(\w)(\S*)/g, function (_, i, r) { | ||
var j = i.toUpperCase() + (r !== null ? r : ""); | ||
return (Object.keys(customReplacements).indexOf(j.toLowerCase()) < | ||
0) ? j : j.toLowerCase(); | ||
return (Object.keys(customReplacements).indexOf(j.toLowerCase()) < 0) ? j : j.toLowerCase(); | ||
}); | ||
@@ -108,5 +104,3 @@ } | ||
// process language specific diactrics chars conversion | ||
ch = lastCharWasSymbol && langChar[ch].match(/[A-Za-z0-9]/) ? | ||
' ' + | ||
langChar[ch] : langChar[ch]; | ||
ch = lastCharWasSymbol && langChar[ch].match(/[A-Za-z0-9]/) ? ' ' + langChar[ch] : langChar[ch]; | ||
@@ -117,5 +111,3 @@ lastCharWasSymbol = false; | ||
// process diactrics chars | ||
ch = lastCharWasSymbol && charMap[ch].match(/[A-Za-z0-9]/) ? | ||
' ' + | ||
charMap[ch] : charMap[ch]; | ||
ch = lastCharWasSymbol && charMap[ch].match(/[A-Za-z0-9]/) ? ' ' + charMap[ch] : charMap[ch]; | ||
@@ -126,12 +118,9 @@ lastCharWasSymbol = false; | ||
// process symbol chars | ||
symbol[ch] && !(uricFlag && uricChars.join('').indexOf(ch) !== -1) && | ||
!(uricNoSlashFlag && uricNoSlashChars.join('').indexOf(ch) !== -1) && | ||
!(markFlag && markChars.join('').indexOf(ch) !== -1)) { | ||
symbol[ch] && !(uricFlag && uricChars.join('') | ||
.indexOf(ch) !== -1) && !(uricNoSlashFlag && uricNoSlashChars.join('') | ||
.indexOf(ch) !== -1) && !(markFlag && markChars.join('') | ||
.indexOf(ch) !== -1)) { | ||
ch = lastCharWasSymbol || result.substr(-1).match( | ||
/[A-Za-z0-9]/) ? | ||
separator + symbol[ch] : symbol[ch]; | ||
ch += input[i + 1] !== void 0 && input[i + 1].match( | ||
/[A-Za-z0-9]/) ? | ||
separator : ''; | ||
ch = lastCharWasSymbol || result.substr(-1).match(/[A-Za-z0-9]/) ? separator + symbol[ch] : symbol[ch]; | ||
ch += input[i + 1] !== void 0 && input[i + 1].match(/[A-Za-z0-9]/) ? separator : ''; | ||
@@ -142,4 +131,3 @@ lastCharWasSymbol = true; | ||
// process latin chars | ||
if (lastCharWasSymbol && (/[A-Za-z0-9]/.test(ch) || result.substr(-1) | ||
.match(/A-Za-z0-9]/))) { | ||
if (lastCharWasSymbol && (/[A-Za-z0-9]/.test(ch) || result.substr(-1).match(/A-Za-z0-9]/))) { | ||
@@ -160,5 +148,3 @@ ch = ' ' + ch; | ||
.replace(new RegExp('\\' + separator + '+', 'g'), separator) | ||
.replace(new RegExp('(^\\' + separator + '+|\\' + separator + | ||
'+$)', | ||
'g'), ''); | ||
.replace(new RegExp('(^\\' + separator + '+|\\' + separator + '+$)', 'g'), ''); | ||
@@ -876,3 +862,3 @@ if (truncate && result.length > truncate) { | ||
// export function for use in AMD | ||
define([], function() { | ||
define([], function () { | ||
return getSlug; | ||
@@ -879,0 +865,0 @@ }); |
{ | ||
"name": "speakingurl", | ||
"version": "0.12.1", | ||
"version": "0.12.3", | ||
"description": "Generate a slug – transliteration with a lot of options", | ||
@@ -12,6 +12,8 @@ "homepage": "http://pid.github.io/speakingurl/", | ||
"bugs": "https://github.com/pid/speakingurl/issues", | ||
"licenses": [{ | ||
"type": "BSD", | ||
"url": "https://raw.github.com/pid/speakingurl/master/LICENSE" | ||
}], | ||
"licenses": [ | ||
{ | ||
"type": "BSD", | ||
"url": "https://raw.github.com/pid/speakingurl/master/LICENSE" | ||
} | ||
], | ||
"keywords": [ | ||
@@ -49,10 +51,14 @@ "slug", | ||
"devDependencies": { | ||
"grunt": "~0.4.2", | ||
"grunt-bumpup": "^0.6.1", | ||
"grunt-contrib-jshint": "^0.10.0", | ||
"grunt-contrib-uglify": "^0.6.0", | ||
"grunt-contrib-watch": "^0.6.1", | ||
"grunt-jsbeautifier": "~0.2.6", | ||
"grunt-release": "^0.7.0", | ||
"grunt-text-replace": "~0.3.10", | ||
"gulp": "^3.8.8", | ||
"gulp-bump": "^0.1.11", | ||
"gulp-header": "^1.1.1", | ||
"gulp-jsbeautifier": "0.0.2", | ||
"gulp-jshint": "^1.8.4", | ||
"gulp-load-plugins": "^0.6.0", | ||
"gulp-mocha": "^1.1.0", | ||
"gulp-rename": "^1.2.0", | ||
"gulp-replace": "^0.4.0", | ||
"gulp-uglify": "^1.0.1", | ||
"jshint-stylish": "^1.0.0", | ||
"minimist": "^1.1.0", | ||
"mocha": "^1.18.2", | ||
@@ -59,0 +65,0 @@ "should": "^4.0.4" |
@@ -37,7 +37,7 @@ # Speaking URL [![NPM version](https://badge.fury.io/js/speakingurl.png)](http://badge.fury.io/js/speakingurl) [![Build Status](https://travis-ci.org/pid/speakingurl.png)](https://travis-ci.org/pid/speakingurl) | ||
- available versions: http://cdnjs.com/libraries/speakingurl/ | ||
- use //cdnjs.cloudflare.com/ajax/libs/speakingurl/0.12.1/speakingurl.min.js | ||
- use //cdnjs.cloudflare.com/ajax/libs/speakingurl/0.12.3/speakingurl.min.js | ||
#### [CDN/maxcdn](https://www.maxcdn.com/) | ||
- available versions: http://www.jsdelivr.com/#!speakingurl | ||
- use //cdn.jsdelivr.net/speakingurl/0.12.1/speakingurl.min.js | ||
- use //cdn.jsdelivr.net/speakingurl/0.12.3/speakingurl.min.js | ||
@@ -44,0 +44,0 @@ ## Usage |
@@ -1,1 +0,7 @@ | ||
/* speakingurl v0.12.1 (c) 2013-2014 Sascha Droste http://pid.github.io/speakingurl/ */!function(){"use strict";var a=function(a,b){var g,h,i,j,k,l="object"==typeof b&&b.maintainCase||!1,m="object"==typeof b&&b.titleCase?b.titleCase:!1,n="object"==typeof b&&"object"==typeof b.custom&&b.custom?b.custom:{},o="object"==typeof b&&b.separator||"-",p="object"==typeof b&&+b.truncate>1&&b.truncate||!1,q="object"==typeof b&&b.uric||!1,r="object"==typeof b&&b.uricNoSlash||!1,s="object"==typeof b&&b.mark||!1,t="object"==typeof b&&b.lang&&f[b.lang]?f[b.lang]:"object"!=typeof b||b.lang!==!1&&b.lang!==!0?f.en:{},u="object"==typeof b&&b.lang&&e[b.lang]?e[b.lang]:"object"!=typeof b||b.lang!==!1&&b.lang!==!0?e.en:{},v=[";","?",":","@","&","=","+","$",",","/"],w=[";","?",":","@","&","=","+","$",","],x=[".","!","~","*","'","(",")"],y="",z=o;if(m&&"number"==typeof m.length&&Array.prototype.toString.call(m)&&m.forEach(function(a){n[a+""]=a+""}),"string"!=typeof a)return"";for("string"==typeof b?o=b:"object"==typeof b&&(q&&(z+=v.join("")),r&&(z+=w.join("")),s&&(z+=x.join(""))),Object.keys(n).forEach(function(b){var d;d=b.length>1?new RegExp("\\b"+c(b)+"\\b","gi"):new RegExp(c(b),"gi"),a=a.replace(d,n[b])}),m&&(a=a.replace(/(\w)(\S*)/g,function(a,b,c){var d=b.toUpperCase()+(null!==c?c:"");return Object.keys(n).indexOf(d.toLowerCase())<0?d:d.toLowerCase()})),z=c(z),a=a.replace(/(^\s+|\s+$)/g,""),k=!1,h=0,j=a.length;j>h;h++)i=a[h],u[i]?(i=k&&u[i].match(/[A-Za-z0-9]/)?" "+u[i]:u[i],k=!1):d[i]?(i=k&&d[i].match(/[A-Za-z0-9]/)?" "+d[i]:d[i],k=!1):!t[i]||q&&-1!==v.join("").indexOf(i)||r&&-1!==w.join("").indexOf(i)||s&&-1!==x.join("").indexOf(i)?(k&&(/[A-Za-z0-9]/.test(i)||y.substr(-1).match(/A-Za-z0-9]/))&&(i=" "+i),k=!1):(i=k||y.substr(-1).match(/[A-Za-z0-9]/)?o+t[i]:t[i],i+=void 0!==a[h+1]&&a[h+1].match(/[A-Za-z0-9]/)?o:"",k=!0),y+=i.replace(new RegExp("[^\\w\\s"+z+"_-]","g"),o);return y=y.replace(/\s+/g,o).replace(new RegExp("\\"+o+"+","g"),o).replace(new RegExp("(^\\"+o+"+|\\"+o+"+$)","g"),""),p&&y.length>p&&(g=y.charAt(p)===o,y=y.slice(0,p),g||(y=y.slice(0,y.lastIndexOf(o)))),l||m||m.length||(y=y.toLowerCase()),y},b=function(b){return function(c){return a(c,b)}},c=function(a){return a.replace(/[-\\^$*+?.()|[\]{}\/]/g,"\\$&")},d={"À":"A","Á":"A","Â":"A","Ã":"A","Ä":"Ae","Å":"A","Æ":"AE","Ç":"C","È":"E","É":"E","Ê":"E","Ë":"E","Ì":"I","Í":"I","Î":"I","Ï":"I","Ð":"D","Ñ":"N","Ò":"O","Ó":"O","Ô":"O","Õ":"O","Ö":"Oe","Ő":"O","Ø":"O","Ù":"U","Ú":"U","Û":"U","Ü":"Ue","Ű":"U","Ý":"Y","Þ":"TH","ß":"ss","à":"a","á":"a","â":"a","ã":"a","ä":"ae","å":"a","æ":"ae","ç":"c","è":"e","é":"e","ê":"e","ë":"e","ì":"i","í":"i","î":"i","ï":"i","ð":"d","ñ":"n","ò":"o","ó":"o","ô":"o","õ":"o","ö":"oe","ő":"o","ø":"o","ù":"u","ú":"u","û":"u","ü":"ue","ű":"u","ý":"y","þ":"th","ÿ":"y","ẞ":"SS","α":"a","β":"v","γ":"g","δ":"d","ε":"e","ζ":"z","η":"i","θ":"th","ι":"i","κ":"k","λ":"l","μ":"m","ν":"n","ξ":"ks","ο":"o","π":"p","ρ":"r","σ":"s","τ":"t","υ":"y","φ":"f","χ":"x","ψ":"ps","ω":"o","ά":"a","έ":"e","ί":"i","ό":"o","ύ":"y","ή":"i","ώ":"o","ς":"s","ϊ":"i","ΰ":"y","ϋ":"y","ΐ":"i","Α":"A","Β":"B","Γ":"G","Δ":"D","Ε":"E","Ζ":"Z","Η":"I","Θ":"TH","Ι":"I","Κ":"K","Λ":"L","Μ":"M","Ν":"N","Ξ":"KS","Ο":"O","Π":"P","Ρ":"R","Σ":"S","Τ":"T","Υ":"Y","Φ":"F","Χ":"X","Ψ":"PS","Ω":"W","Ά":"A","Έ":"E","Ί":"I","Ό":"O","Ύ":"Y","Ή":"I","Ώ":"O","Ϊ":"I","Ϋ":"Y","ş":"s","Ş":"S","ı":"i","İ":"I","ğ":"g","Ğ":"G","Ќ":"Kj","ќ":"kj","Љ":"Lj","љ":"lj","Њ":"Nj","њ":"nj","Тс":"Ts","тс":"ts","а":"a","б":"b","в":"v","г":"g","д":"d","е":"e","ё":"yo","ж":"zh","з":"z","и":"i","й":"j","к":"k","л":"l","м":"m","н":"n","о":"o","п":"p","р":"r","с":"s","т":"t","у":"u","ф":"f","х":"h","ц":"c","ч":"ch","ш":"sh","щ":"sh","ъ":"","ы":"y","ь":"","э":"e","ю":"yu","я":"ya","А":"A","Б":"B","В":"V","Г":"G","Д":"D","Е":"E","Ё":"Yo","Ж":"Zh","З":"Z","И":"I","Й":"J","К":"K","Л":"L","М":"M","Н":"N","О":"O","П":"P","Р":"R","С":"S","Т":"T","У":"U","Ф":"F","Х":"H","Ц":"C","Ч":"Ch","Ш":"Sh","Щ":"Sh","Ъ":"","Ы":"Y","Ь":"","Э":"E","Ю":"Yu","Я":"Ya","Є":"Ye","І":"I","Ї":"Yi","Ґ":"G","є":"ye","і":"i","ї":"yi","ґ":"g","č":"c","ď":"d","ě":"e","ň":"n","ř":"r","š":"s","ť":"t","ů":"u","ž":"z","Č":"C","Ď":"D","Ě":"E","Ň":"N","Ř":"R","Š":"S","Ť":"T","Ů":"U","Ž":"Z","ľ":"l","ĺ":"l","ŕ":"r","Ľ":"L","Ĺ":"L","Ŕ":"R","ą":"a","ć":"c","ę":"e","ł":"l","ń":"n","ś":"s","ź":"z","ż":"z","Ą":"A","Ć":"C","Ę":"E","Ł":"L","Ń":"N","Ś":"S","Ź":"Z","Ż":"Z","ā":"a","ē":"e","ģ":"g","ī":"i","ķ":"k","ļ":"l","ņ":"n","ū":"u","Ā":"A","Ē":"E","Ģ":"G","Ī":"I","Ķ":"k","Ļ":"L","Ņ":"N","Ū":"U","ا":"a","أ":"a","إ":"i","آ":"aa","ؤ":"u","ئ":"e","ء":"a","ب":"b","ت":"t","ث":"th","ج":"j","ح":"h","خ":"kh","د":"d","ذ":"th","ر":"r","ز":"z","س":"s","ش":"sh","ص":"s","ض":"dh","ط":"t","ظ":"z","ع":"a","غ":"gh","ف":"f","ق":"q","ك":"k","ل":"l","م":"m","ن":"n","ه":"h","و":"w","ي":"y","ى":"a","ة":"h","ﻻ":"la","ﻷ":"laa","ﻹ":"lai","ﻵ":"laa","َ":"a","ً":"an","ِ":"e","ٍ":"en","ُ":"u","ٌ":"on","ْ":"","٠":"0","١":"1","٢":"2","٣":"3","٤":"4","٥":"5","٦":"6","٧":"7","٨":"8","٩":"9","“":'"',"”":'"',"‘":"'","’":"'","∂":"d","ƒ":"f","™":"(TM)","©":"(C)","œ":"oe","Œ":"OE","®":"(R)","†":"+","℠":"(SM)","…":"...","˚":"o","º":"o","ª":"a","•":"*",$:"USD","€":"EUR","₢":"BRN","₣":"FRF","£":"GBP","₤":"ITL","₦":"NGN","₧":"ESP","₩":"KRW","₪":"ILS","₫":"VND","₭":"LAK","₮":"MNT","₯":"GRD","₱":"ARS","₲":"PYG","₳":"ARA","₴":"UAH","₵":"GHS","¢":"cent","¥":"CNY","元":"CNY","円":"YEN","﷼":"IRR","₠":"EWE","฿":"THB","₨":"INR","₹":"INR","₰":"PF","đ":"d","Đ":"D","ẹ":"e","Ẹ":"E","ẽ":"e","Ẽ":"E","ế":"e","Ế":"E","ề":"e","Ề":"E","ệ":"e","Ệ":"E","ễ":"e","Ễ":"E","ọ":"o","Ọ":"o","ố":"o","Ố":"O","ồ":"o","Ồ":"O","ộ":"o","Ộ":"O","ỗ":"o","Ỗ":"O","ơ":"o","Ơ":"O","ớ":"o","Ớ":"O","ờ":"o","Ờ":"O","ợ":"o","Ợ":"O","ỡ":"o","Ỡ":"O","ị":"i","Ị":"I","ĩ":"i","Ĩ":"I","ụ":"u","Ụ":"U","ũ":"u","Ũ":"U","ư":"u","Ư":"U","ứ":"u","Ứ":"U","ừ":"u","Ừ":"U","ự":"u","Ự":"U","ữ":"u","Ữ":"U","ỳ":"y","Ỳ":"Y","ỵ":"y","Ỵ":"Y","ỹ":"y","Ỹ":"Y","ạ":"a","Ạ":"A","ấ":"a","Ấ":"A","ầ":"a","Ầ":"A","ậ":"a","Ậ":"A","ẫ":"a","Ẫ":"A","ă":"a","Ă":"A","ắ":"a","Ắ":"A","ằ":"a","Ằ":"A","ặ":"a","Ặ":"A","ẵ":"a","Ẵ":"A"},e={en:{},sk:{"ä":"a","Ä":"A"}},f={ar:{"∆":"delta","∞":"la-nihaya","♥":"hob","&":"wa","|":"aw","<":"aqal-men",">":"akbar-men","∑":"majmou","¤":"omla"},de:{"∆":"delta","∞":"unendlich","♥":"Liebe","&":"und","|":"oder","<":"kleiner als",">":"groesser als","∑":"Summe von","¤":"Waehrung"},nl:{"∆":"delta","∞":"oneindig","♥":"liefde","&":"en","|":"of","<":"kleiner dan",">":"groter dan","∑":"som","¤":"valuta"},en:{"∆":"delta","∞":"infinity","♥":"love","&":"and","|":"or","<":"less than",">":"greater than","∑":"sum","¤":"currency"},es:{"∆":"delta","∞":"infinito","♥":"amor","&":"y","|":"u","<":"menos que",">":"mas que","∑":"suma de los","¤":"moneda"},fr:{"∆":"delta","∞":"infiniment","♥":"Amour","&":"et","|":"ou","<":"moins que",">":"superieure a","∑":"somme des","¤":"monnaie"},pt:{"∆":"delta","∞":"infinito","♥":"amor","&":"e","|":"ou","<":"menor que",">":"maior que","∑":"soma","¤":"moeda"},ru:{"∆":"delta","∞":"beskonechno","♥":"lubov","&":"i","|":"ili","<":"menshe",">":"bolshe","∑":"summa","¤":"valjuta"},cz:{"∆":"delta","∞":"nekonecno","♥":"laska","&":"a","|":"nebo","<":"mene jako",">":"vice jako","∑":"soucet","¤":"mena"},sk:{"∆":"delta","∞":"nekonecno","♥":"laska","&":"a","|":"alebo","<":"menej ako",">":"viac ako","∑":"sucet","¤":"mena"},vn:{"∆":"delta","∞":"vo cuc","♥":"yeu","&":"va","|":"hoac","<":"nho hon",">":"lon hon","∑":"tong","¤":"tien te"}};if("undefined"!=typeof module&&module.exports)module.exports=a,module.exports.createSlug=b;else if("undefined"!=typeof define&&define.amd)define([],function(){return a});else try{if(window.getSlug||window.createSlug)throw"speakingurl: globals exists /(getSlug|createSlug)/";window.getSlug=a,window.createSlug=b}catch(g){}}(); | ||
/** | ||
* speakingurl | ||
* @version v0.12.3 | ||
* @link http://pid.github.io/speakingurl/ | ||
* @license BSD | ||
* @author Sascha Droste | ||
*/!function(){"use strict";var e=function(e,a){var l,r,u,s,c,f="object"==typeof a&&a.maintainCase||!1,g="object"==typeof a&&a.titleCase?a.titleCase:!1,d="object"==typeof a&&"object"==typeof a.custom&&a.custom?a.custom:{},m="object"==typeof a&&a.separator||"-",h="object"==typeof a&&+a.truncate>1&&a.truncate||!1,p="object"==typeof a&&a.uric||!1,y="object"==typeof a&&a.uricNoSlash||!1,A="object"==typeof a&&a.mark||!1,j="object"==typeof a&&a.lang&&i[a.lang]?i[a.lang]:"object"!=typeof a||a.lang!==!1&&a.lang!==!0?i.en:{},b="object"==typeof a&&a.lang&&t[a.lang]?t[a.lang]:"object"!=typeof a||a.lang!==!1&&a.lang!==!0?t.en:{},E=[";","?",":","@","&","=","+","$",",","/"],O=[";","?",":","@","&","=","+","$",","],S=[".","!","~","*","'","(",")"],k="",w=m;if(g&&"number"==typeof g.length&&Array.prototype.toString.call(g)&&g.forEach(function(e){d[e+""]=e+""}),"string"!=typeof e)return"";for("string"==typeof a?m=a:"object"==typeof a&&(p&&(w+=E.join("")),y&&(w+=O.join("")),A&&(w+=S.join(""))),Object.keys(d).forEach(function(a){var n;n=a.length>1?new RegExp("\\b"+o(a)+"\\b","gi"):new RegExp(o(a),"gi"),e=e.replace(n,d[a])}),g&&(e=e.replace(/(\w)(\S*)/g,function(e,a,o){var n=a.toUpperCase()+(null!==o?o:"");return Object.keys(d).indexOf(n.toLowerCase())<0?n:n.toLowerCase()})),w=o(w),e=e.replace(/(^\s+|\s+$)/g,""),c=!1,r=0,s=e.length;s>r;r++)u=e[r],b[u]?(u=c&&b[u].match(/[A-Za-z0-9]/)?" "+b[u]:b[u],c=!1):n[u]?(u=c&&n[u].match(/[A-Za-z0-9]/)?" "+n[u]:n[u],c=!1):!j[u]||p&&-1!==E.join("").indexOf(u)||y&&-1!==O.join("").indexOf(u)||A&&-1!==S.join("").indexOf(u)?(c&&(/[A-Za-z0-9]/.test(u)||k.substr(-1).match(/A-Za-z0-9]/))&&(u=" "+u),c=!1):(u=c||k.substr(-1).match(/[A-Za-z0-9]/)?m+j[u]:j[u],u+=void 0!==e[r+1]&&e[r+1].match(/[A-Za-z0-9]/)?m:"",c=!0),k+=u.replace(new RegExp("[^\\w\\s"+w+"_-]","g"),m);return k=k.replace(/\s+/g,m).replace(new RegExp("\\"+m+"+","g"),m).replace(new RegExp("(^\\"+m+"+|\\"+m+"+$)","g"),""),h&&k.length>h&&(l=k.charAt(h)===m,k=k.slice(0,h),l||(k=k.slice(0,k.lastIndexOf(m)))),f||g||g.length||(k=k.toLowerCase()),k},a=function(a){return function(o){return e(o,a)}},o=function(e){return e.replace(/[-\\^$*+?.()|[\]{}\/]/g,"\\$&")},n={"À":"A","Á":"A","Â":"A","Ã":"A","Ä":"Ae","Å":"A","Æ":"AE","Ç":"C","È":"E","É":"E","Ê":"E","Ë":"E","Ì":"I","Í":"I","Î":"I","Ï":"I","Ð":"D","Ñ":"N","Ò":"O","Ó":"O","Ô":"O","Õ":"O","Ö":"Oe","Ő":"O","Ø":"O","Ù":"U","Ú":"U","Û":"U","Ü":"Ue","Ű":"U","Ý":"Y","Þ":"TH","ß":"ss","à":"a","á":"a","â":"a","ã":"a","ä":"ae","å":"a","æ":"ae","ç":"c","è":"e","é":"e","ê":"e","ë":"e","ì":"i","í":"i","î":"i","ï":"i","ð":"d","ñ":"n","ò":"o","ó":"o","ô":"o","õ":"o","ö":"oe","ő":"o","ø":"o","ù":"u","ú":"u","û":"u","ü":"ue","ű":"u","ý":"y","þ":"th","ÿ":"y","ẞ":"SS","α":"a","β":"v","γ":"g","δ":"d","ε":"e","ζ":"z","η":"i","θ":"th","ι":"i","κ":"k","λ":"l","μ":"m","ν":"n","ξ":"ks","ο":"o","π":"p","ρ":"r","σ":"s","τ":"t","υ":"y","φ":"f","χ":"x","ψ":"ps","ω":"o","ά":"a","έ":"e","ί":"i","ό":"o","ύ":"y","ή":"i","ώ":"o","ς":"s","ϊ":"i","ΰ":"y","ϋ":"y","ΐ":"i","Α":"A","Β":"B","Γ":"G","Δ":"D","Ε":"E","Ζ":"Z","Η":"I","Θ":"TH","Ι":"I","Κ":"K","Λ":"L","Μ":"M","Ν":"N","Ξ":"KS","Ο":"O","Π":"P","Ρ":"R","Σ":"S","Τ":"T","Υ":"Y","Φ":"F","Χ":"X","Ψ":"PS","Ω":"W","Ά":"A","Έ":"E","Ί":"I","Ό":"O","Ύ":"Y","Ή":"I","Ώ":"O","Ϊ":"I","Ϋ":"Y","ş":"s","Ş":"S","ı":"i","İ":"I","ğ":"g","Ğ":"G","Ќ":"Kj","ќ":"kj","Љ":"Lj","љ":"lj","Њ":"Nj","њ":"nj","Тс":"Ts","тс":"ts","а":"a","б":"b","в":"v","г":"g","д":"d","е":"e","ё":"yo","ж":"zh","з":"z","и":"i","й":"j","к":"k","л":"l","м":"m","н":"n","о":"o","п":"p","р":"r","с":"s","т":"t","у":"u","ф":"f","х":"h","ц":"c","ч":"ch","ш":"sh","щ":"sh","ъ":"","ы":"y","ь":"","э":"e","ю":"yu","я":"ya","А":"A","Б":"B","В":"V","Г":"G","Д":"D","Е":"E","Ё":"Yo","Ж":"Zh","З":"Z","И":"I","Й":"J","К":"K","Л":"L","М":"M","Н":"N","О":"O","П":"P","Р":"R","С":"S","Т":"T","У":"U","Ф":"F","Х":"H","Ц":"C","Ч":"Ch","Ш":"Sh","Щ":"Sh","Ъ":"","Ы":"Y","Ь":"","Э":"E","Ю":"Yu","Я":"Ya","Є":"Ye","І":"I","Ї":"Yi","Ґ":"G","є":"ye","і":"i","ї":"yi","ґ":"g","č":"c","ď":"d","ě":"e","ň":"n","ř":"r","š":"s","ť":"t","ů":"u","ž":"z","Č":"C","Ď":"D","Ě":"E","Ň":"N","Ř":"R","Š":"S","Ť":"T","Ů":"U","Ž":"Z","ľ":"l","ĺ":"l","ŕ":"r","Ľ":"L","Ĺ":"L","Ŕ":"R","ą":"a","ć":"c","ę":"e","ł":"l","ń":"n","ś":"s","ź":"z","ż":"z","Ą":"A","Ć":"C","Ę":"E","Ł":"L","Ń":"N","Ś":"S","Ź":"Z","Ż":"Z","ā":"a","ē":"e","ģ":"g","ī":"i","ķ":"k","ļ":"l","ņ":"n","ū":"u","Ā":"A","Ē":"E","Ģ":"G","Ī":"I","Ķ":"k","Ļ":"L","Ņ":"N","Ū":"U","ا":"a","أ":"a","إ":"i","آ":"aa","ؤ":"u","ئ":"e","ء":"a","ب":"b","ت":"t","ث":"th","ج":"j","ح":"h","خ":"kh","د":"d","ذ":"th","ر":"r","ز":"z","س":"s","ش":"sh","ص":"s","ض":"dh","ط":"t","ظ":"z","ع":"a","غ":"gh","ف":"f","ق":"q","ك":"k","ل":"l","م":"m","ن":"n","ه":"h","و":"w","ي":"y","ى":"a","ة":"h","ﻻ":"la","ﻷ":"laa","ﻹ":"lai","ﻵ":"laa","َ":"a","ً":"an","ِ":"e","ٍ":"en","ُ":"u","ٌ":"on","ْ":"","٠":"0","١":"1","٢":"2","٣":"3","٤":"4","٥":"5","٦":"6","٧":"7","٨":"8","٩":"9","“":'"',"”":'"',"‘":"'","’":"'","∂":"d","ƒ":"f","™":"(TM)","©":"(C)","œ":"oe","Œ":"OE","®":"(R)","†":"+","℠":"(SM)","…":"...","˚":"o","º":"o","ª":"a","•":"*",$:"USD","€":"EUR","₢":"BRN","₣":"FRF","£":"GBP","₤":"ITL","₦":"NGN","₧":"ESP","₩":"KRW","₪":"ILS","₫":"VND","₭":"LAK","₮":"MNT","₯":"GRD","₱":"ARS","₲":"PYG","₳":"ARA","₴":"UAH","₵":"GHS","¢":"cent","¥":"CNY","元":"CNY","円":"YEN","﷼":"IRR","₠":"EWE","฿":"THB","₨":"INR","₹":"INR","₰":"PF","đ":"d","Đ":"D","ẹ":"e","Ẹ":"E","ẽ":"e","Ẽ":"E","ế":"e","Ế":"E","ề":"e","Ề":"E","ệ":"e","Ệ":"E","ễ":"e","Ễ":"E","ọ":"o","Ọ":"o","ố":"o","Ố":"O","ồ":"o","Ồ":"O","ộ":"o","Ộ":"O","ỗ":"o","Ỗ":"O","ơ":"o","Ơ":"O","ớ":"o","Ớ":"O","ờ":"o","Ờ":"O","ợ":"o","Ợ":"O","ỡ":"o","Ỡ":"O","ị":"i","Ị":"I","ĩ":"i","Ĩ":"I","ụ":"u","Ụ":"U","ũ":"u","Ũ":"U","ư":"u","Ư":"U","ứ":"u","Ứ":"U","ừ":"u","Ừ":"U","ự":"u","Ự":"U","ữ":"u","Ữ":"U","ỳ":"y","Ỳ":"Y","ỵ":"y","Ỵ":"Y","ỹ":"y","Ỹ":"Y","ạ":"a","Ạ":"A","ấ":"a","Ấ":"A","ầ":"a","Ầ":"A","ậ":"a","Ậ":"A","ẫ":"a","Ẫ":"A","ă":"a","Ă":"A","ắ":"a","Ắ":"A","ằ":"a","Ằ":"A","ặ":"a","Ặ":"A","ẵ":"a","Ẵ":"A"},t={en:{},sk:{"ä":"a","Ä":"A"}},i={ar:{"∆":"delta","∞":"la-nihaya","♥":"hob","&":"wa","|":"aw","<":"aqal-men",">":"akbar-men","∑":"majmou","¤":"omla"},de:{"∆":"delta","∞":"unendlich","♥":"Liebe","&":"und","|":"oder","<":"kleiner als",">":"groesser als","∑":"Summe von","¤":"Waehrung"},nl:{"∆":"delta","∞":"oneindig","♥":"liefde","&":"en","|":"of","<":"kleiner dan",">":"groter dan","∑":"som","¤":"valuta"},en:{"∆":"delta","∞":"infinity","♥":"love","&":"and","|":"or","<":"less than",">":"greater than","∑":"sum","¤":"currency"},es:{"∆":"delta","∞":"infinito","♥":"amor","&":"y","|":"u","<":"menos que",">":"mas que","∑":"suma de los","¤":"moneda"},fr:{"∆":"delta","∞":"infiniment","♥":"Amour","&":"et","|":"ou","<":"moins que",">":"superieure a","∑":"somme des","¤":"monnaie"},pt:{"∆":"delta","∞":"infinito","♥":"amor","&":"e","|":"ou","<":"menor que",">":"maior que","∑":"soma","¤":"moeda"},ru:{"∆":"delta","∞":"beskonechno","♥":"lubov","&":"i","|":"ili","<":"menshe",">":"bolshe","∑":"summa","¤":"valjuta"},cz:{"∆":"delta","∞":"nekonecno","♥":"laska","&":"a","|":"nebo","<":"mene jako",">":"vice jako","∑":"soucet","¤":"mena"},sk:{"∆":"delta","∞":"nekonecno","♥":"laska","&":"a","|":"alebo","<":"menej ako",">":"viac ako","∑":"sucet","¤":"mena"},vn:{"∆":"delta","∞":"vo cuc","♥":"yeu","&":"va","|":"hoac","<":"nho hon",">":"lon hon","∑":"tong","¤":"tien te"}};if("undefined"!=typeof module&&module.exports)module.exports=e,module.exports.createSlug=a;else if("undefined"!=typeof define&&define.amd)define([],function(){return e});else try{if(window.getSlug||window.createSlug)throw"speakingurl: globals exists /(getSlug|createSlug)/";window.getSlug=e,window.createSlug=a}catch(l){}}(); |
@@ -5,10 +5,11 @@ /* global describe,it */ | ||
describe('getSlug translate arabic letters', function() { | ||
describe('getSlug translate arabic letters', function () { | ||
'use strict'; | ||
it('should be ', function(done) { | ||
it('should be ', function (done) { | ||
getSlug('بشس تاقفغقف - ت ب ي ق', { | ||
language: 'ar' | ||
}).should.eql('bshs-taqfghqf-t-b-y-q'); | ||
}) | ||
.should.eql('bshs-taqfghqf-t-b-y-q'); | ||
@@ -15,0 +16,0 @@ done(); |
/* global describe,it */ | ||
describe('getSlug create', function() { | ||
describe('getSlug create', function () { | ||
'use strict'; | ||
it('with symbols', function(done) { | ||
var getSlug = require('../lib').createSlug({ | ||
lang: 'en', | ||
uric: true, | ||
uricNoSlash: true, | ||
mark: true | ||
}); | ||
it('with symbols', function (done) { | ||
getSlug('Foo (♥) ; Baz=Bar').should.eql('foo-(love)-;-baz=bar'); | ||
var getSlug = require('../lib') | ||
.createSlug({ | ||
lang: 'en', | ||
uric: true, | ||
uricNoSlash: true, | ||
mark: true | ||
}); | ||
getSlug('Foo (♥) ; Baz=Bar') | ||
.should.eql('foo-(love)-;-baz=bar'); | ||
done(); | ||
}); | ||
it('without options', function(done) { | ||
var getSlug = require('../lib').createSlug(); | ||
it('without options', function (done) { | ||
getSlug('Foo Bar Baz').should.eql('foo-bar-baz'); | ||
var getSlug = require('../lib') | ||
.createSlug(); | ||
getSlug('Foo Bar Baz') | ||
.should.eql('foo-bar-baz'); | ||
done(); | ||
}); | ||
it('with empty options', function(done) { | ||
var getSlug = require('../lib').createSlug({}); | ||
it('with empty options', function (done) { | ||
getSlug('Foo Bar Baz').should.eql('foo-bar-baz'); | ||
var getSlug = require('../lib') | ||
.createSlug({}); | ||
getSlug('Foo Bar Baz') | ||
.should.eql('foo-bar-baz'); | ||
done(); | ||
}); | ||
it('with maintainCase', function(done) { | ||
var getSlug = require('../lib').createSlug({ | ||
maintainCase: true | ||
}); | ||
it('with maintainCase', function (done) { | ||
getSlug('Foo Bar Baz').should.eql('Foo-Bar-Baz'); | ||
var getSlug = require('../lib') | ||
.createSlug({ | ||
maintainCase: true | ||
}); | ||
getSlug('Foo Bar Baz') | ||
.should.eql('Foo-Bar-Baz'); | ||
done(); | ||
}); | ||
it('with uric', function(done) { | ||
var getSlug = require('../lib').createSlug({ | ||
uric: true | ||
}); | ||
it('with uric', function (done) { | ||
getSlug(' :80:/Foo/Bar/Baz:Foo').should.eql(':80:/foo/bar/baz:foo'); | ||
var getSlug = require('../lib') | ||
.createSlug({ | ||
uric: true | ||
}); | ||
getSlug(' :80:/Foo/Bar/Baz:Foo') | ||
.should.eql(':80:/foo/bar/baz:foo'); | ||
done(); | ||
}); | ||
it('with uricNoSlash', function(done) { | ||
var getSlug = require('../lib').createSlug({ | ||
uricNoSlash: true | ||
}); | ||
it('with uricNoSlash', function (done) { | ||
getSlug('Foo/ Bar= Baz').should.eql('foo-bar=-baz'); | ||
var getSlug = require('../lib') | ||
.createSlug({ | ||
uricNoSlash: true | ||
}); | ||
getSlug('Foo/ Bar= Baz') | ||
.should.eql('foo-bar=-baz'); | ||
done(); | ||
}); | ||
it('with mark', function(done) { | ||
var getSlug = require('../lib').createSlug({ | ||
mark: true | ||
}); | ||
it('with mark', function (done) { | ||
getSlug('Foo* Bar Baz').should.eql('foo*-bar-baz'); | ||
var getSlug = require('../lib') | ||
.createSlug({ | ||
mark: true | ||
}); | ||
getSlug('Foo* Bar Baz') | ||
.should.eql('foo*-bar-baz'); | ||
done(); | ||
}); | ||
it('with truncate', function(done) { | ||
var getSlug = require('../lib').createSlug({ | ||
truncate: 15 | ||
}); | ||
it('with truncate', function (done) { | ||
getSlug('Foo* Foobar FooBarBaz').should.eql('foo-foobar'); | ||
var getSlug = require('../lib') | ||
.createSlug({ | ||
truncate: 15 | ||
}); | ||
getSlug('Foo* Foobar FooBarBaz') | ||
.should.eql('foo-foobar'); | ||
done(); | ||
}); | ||
it('with separator', function(done) { | ||
var getSlug = require('../lib').createSlug({ | ||
separator: '_' | ||
}); | ||
it('with separator', function (done) { | ||
getSlug('Foo* Foobar FooBarBaz').should.eql('foo_foobar_foobarbaz'); | ||
var getSlug = require('../lib') | ||
.createSlug({ | ||
separator: '_' | ||
}); | ||
getSlug('Foo* Foobar FooBarBaz') | ||
.should.eql('foo_foobar_foobarbaz'); | ||
done(); | ||
}); | ||
it('with mark and maintainCase', function(done) { | ||
var getSlug = require('../lib').createSlug({ | ||
mark: true, | ||
maintainCase: true | ||
}); | ||
it('with mark and maintainCase', function (done) { | ||
getSlug('Foo* Bar Baz').should.eql('Foo*-Bar-Baz'); | ||
var getSlug = require('../lib') | ||
.createSlug({ | ||
mark: true, | ||
maintainCase: true | ||
}); | ||
getSlug('Foo* Bar Baz') | ||
.should.eql('Foo*-Bar-Baz'); | ||
done(); | ||
}); | ||
it('with custom chars replacement', function(done) { | ||
var getSlug = require('../lib').createSlug({ | ||
custom: { | ||
'*': 'o' | ||
} | ||
}); | ||
it('with custom chars replacement', function (done) { | ||
getSlug('xyl*ph*n').should.eql('xylophon'); | ||
var getSlug = require('../lib') | ||
.createSlug({ | ||
custom: { | ||
'*': 'o' | ||
} | ||
}); | ||
getSlug('xyl*ph*n') | ||
.should.eql('xylophon'); | ||
done(); | ||
}); | ||
it('with custom chars replacement with not allowed target char', function(done) { | ||
var getSlug = require('../lib').createSlug({ | ||
custom: { | ||
'o': '*' | ||
} | ||
}); | ||
it('with custom chars leet replacement', function (done) { | ||
getSlug('xylophon').should.eql('xyl-ph-n'); | ||
var getSlug = require('../lib') | ||
.createSlug({ | ||
custom: { | ||
'a': '4', | ||
'b': '8', | ||
'e': '3', | ||
'g': '6', | ||
'l': '1', | ||
'o': '0', | ||
's': '5', | ||
't': '7' | ||
}, | ||
lang: false | ||
}); | ||
getSlug('apbpepgplpopspt') | ||
.should.eql('4p8p3p6p1p0p5p7'); | ||
getSlug('papbpepgplpopsptp') | ||
.should.eql('p4p8p3p6p1p0p5p7p'); | ||
getSlug('qabqegqloqst') | ||
.should.eql('q48q36q10q57'); | ||
getSlug('abeglost') | ||
.should.eql('48361057'); | ||
done(); | ||
}); | ||
it('with custom chars replacement with allowed target char, option mark', function(done) { | ||
var getSlug = require('../lib').createSlug({ | ||
custom: { | ||
'o': '*' | ||
}, | ||
mark: true | ||
}); | ||
it('with custom chars replacement with not allowed target char', function (done) { | ||
getSlug('xylophon').should.eql('xyl*ph*n'); | ||
var getSlug = require('../lib') | ||
.createSlug({ | ||
custom: { | ||
'o': '*' | ||
} | ||
}); | ||
getSlug('xylophon') | ||
.should.eql('xyl-ph-n'); | ||
done(); | ||
}); | ||
it('with custom chars replacement with option mark', function(done) { | ||
var getSlug = require('../lib').createSlug({ | ||
custom: { | ||
'*': 'o' | ||
}, | ||
mark: true | ||
}); | ||
it('with custom chars replacement with allowed target char, option mark', function (done) { | ||
getSlug('xyl*ph*n').should.eql('xylophon'); | ||
var getSlug = require('../lib') | ||
.createSlug({ | ||
custom: { | ||
'o': '*' | ||
}, | ||
mark: true | ||
}); | ||
getSlug('xylophon') | ||
.should.eql('xyl*ph*n'); | ||
done(); | ||
}); | ||
it('with custom char to string replacement', function(done) { | ||
var getSlug = require('../lib').createSlug({ | ||
custom: { | ||
'*': 'STAR', | ||
'q': 'qqq', | ||
'and': '', | ||
'or': '' | ||
} | ||
}); | ||
it('with custom chars replacement with option mark', function (done) { | ||
getSlug('xyl*ph*n').should.eql('xylstarphstarn'); | ||
getSlug('quack').should.eql('qqquack'); | ||
getSlug('Foo and Bar or Baz').should.eql('foo-bar-baz'); | ||
var getSlug = require('../lib') | ||
.createSlug({ | ||
custom: { | ||
'*': 'o' | ||
}, | ||
mark: true | ||
}); | ||
getSlug('xyl*ph*n') | ||
.should.eql('xylophon'); | ||
done(); | ||
}); | ||
it('with custom string replacement', function(done) { | ||
var getSlug = require('../lib').createSlug({ | ||
custom: { | ||
'and': 'und', | ||
'or': 'oder', | ||
'*': ' and ' | ||
} | ||
}); | ||
it('with custom char to string replacement', function (done) { | ||
getSlug('bus and train').should.eql('bus-und-train'); | ||
getSlug('bus or train').should.eql('bus-oder-train'); | ||
getSlug('busandtrain').should.eql('busandtrain'); | ||
getSlug('busortrain').should.eql('busortrain'); | ||
getSlug('bus*train').should.eql('bus-and-train'); | ||
var getSlug = require('../lib') | ||
.createSlug({ | ||
custom: { | ||
'*': 'STAR', | ||
'q': 'qqq', | ||
'and': '', | ||
'or': '' | ||
} | ||
}); | ||
getSlug('bus and train bus and train').should.eql('bus-und-train-bus-und-train'); | ||
getSlug('bus or train bus or train').should.eql('bus-oder-train-bus-oder-train'); | ||
getSlug('busandtrain busandtrain').should.eql('busandtrain-busandtrain'); | ||
getSlug('busortrain busortrain').should.eql('busortrain-busortrain'); | ||
getSlug('xyl*ph*n') | ||
.should.eql('xylstarphstarn'); | ||
getSlug('quack') | ||
.should.eql('qqquack'); | ||
getSlug('Foo and Bar or Baz') | ||
.should.eql('foo-bar-baz'); | ||
@@ -196,39 +249,88 @@ done(); | ||
it('with custom string replacement with option mark', function(done) { | ||
var getSlug = require('../lib').createSlug({ | ||
custom: { | ||
'*': 'STAR', | ||
'q': 'qqq', | ||
'z': '' | ||
}, | ||
mark: true | ||
}); | ||
it('with custom string replacement', function (done) { | ||
getSlug('xyl*ph*n').should.eql('xylstarphstarn'); | ||
getSlug('qxxx').should.eql('qqqxxx'); | ||
getSlug('xxxqxxx').should.eql('xxxqqqxxx'); | ||
getSlug('qqq').should.eql('qqqqqqqqq'); | ||
getSlug('*q*').should.eql('starqqqstar'); | ||
getSlug('zoo').should.eql('oo'); | ||
getSlug('zooz').should.eql('oo'); | ||
var getSlug = require('../lib') | ||
.createSlug({ | ||
custom: { | ||
'and': 'und', | ||
'or': 'oder', | ||
'*': ' and ' | ||
} | ||
}); | ||
getSlug('bus and train') | ||
.should.eql('bus-und-train'); | ||
getSlug('bus or train') | ||
.should.eql('bus-oder-train'); | ||
getSlug('busandtrain') | ||
.should.eql('busandtrain'); | ||
getSlug('busortrain') | ||
.should.eql('busortrain'); | ||
getSlug('bus*train') | ||
.should.eql('bus-and-train'); | ||
getSlug('bus and train bus and train') | ||
.should.eql('bus-und-train-bus-und-train'); | ||
getSlug('bus or train bus or train') | ||
.should.eql('bus-oder-train-bus-oder-train'); | ||
getSlug('busandtrain busandtrain') | ||
.should.eql('busandtrain-busandtrain'); | ||
getSlug('busortrain busortrain') | ||
.should.eql('busortrain-busortrain'); | ||
done(); | ||
}); | ||
it('with custom string replacement with option maintainCase', function(done) { | ||
var getSlug = require('../lib').createSlug({ | ||
custom: { | ||
'*': 'STAR', | ||
'q': 'qqq', | ||
}, | ||
maintainCase: true | ||
}); | ||
it('with custom string replacement with option mark', function (done) { | ||
getSlug('xyl*ph*n').should.eql('xylSTARphSTARn'); | ||
getSlug('qXXX').should.eql('qqqXXX'); | ||
getSlug('qqq').should.eql('qqqqqqqqq'); | ||
getSlug('*q*').should.eql('STARqqqSTAR'); | ||
var getSlug = require('../lib') | ||
.createSlug({ | ||
custom: { | ||
'*': 'STAR', | ||
'q': 'qqq', | ||
'z': '' | ||
}, | ||
mark: true | ||
}); | ||
getSlug('xyl*ph*n') | ||
.should.eql('xylstarphstarn'); | ||
getSlug('qxxx') | ||
.should.eql('qqqxxx'); | ||
getSlug('xxxqxxx') | ||
.should.eql('xxxqqqxxx'); | ||
getSlug('qqq') | ||
.should.eql('qqqqqqqqq'); | ||
getSlug('*q*') | ||
.should.eql('starqqqstar'); | ||
getSlug('zoo') | ||
.should.eql('oo'); | ||
getSlug('zooz') | ||
.should.eql('oo'); | ||
done(); | ||
}); | ||
it('with custom string replacement with option maintainCase', function (done) { | ||
var getSlug = require('../lib') | ||
.createSlug({ | ||
custom: { | ||
'*': 'STAR', | ||
'q': 'qqq', | ||
}, | ||
maintainCase: true | ||
}); | ||
getSlug('xyl*ph*n') | ||
.should.eql('xylSTARphSTARn'); | ||
getSlug('qXXX') | ||
.should.eql('qqqXXX'); | ||
getSlug('qqq') | ||
.should.eql('qqqqqqqqq'); | ||
getSlug('*q*') | ||
.should.eql('STARqqqSTAR'); | ||
done(); | ||
}); | ||
}); |
@@ -5,8 +5,9 @@ /* global describe,it */ | ||
describe('getSlug defaults', function() { | ||
describe('getSlug defaults', function () { | ||
'use strict'; | ||
it('should replace whitespaces with separator', function(done) { | ||
it('should replace whitespaces with separator', function (done) { | ||
getSlug('foo bar baz').should.eql('foo-bar-baz'); | ||
getSlug('foo bar baz') | ||
.should.eql('foo-bar-baz'); | ||
@@ -16,5 +17,6 @@ done(); | ||
it('should remove trailing space if any', function(done) { | ||
it('should remove trailing space if any', function (done) { | ||
getSlug(' foo bar baz ').should.eql('foo-bar-baz'); | ||
getSlug(' foo bar baz ') | ||
.should.eql('foo-bar-baz'); | ||
@@ -24,5 +26,6 @@ done(); | ||
it('should remove multiple whitespaces', function(done) { | ||
it('should remove multiple whitespaces', function (done) { | ||
getSlug(' foo bar baz FOO BAR BAZ ').should.eql('foo-bar-baz-foo-bar-baz'); | ||
getSlug(' foo bar baz FOO BAR BAZ ') | ||
.should.eql('foo-bar-baz-foo-bar-baz'); | ||
@@ -32,7 +35,10 @@ done(); | ||
it('should remove multiple separators at start and end', function(done) { | ||
it('should remove multiple separators at start and end', function (done) { | ||
getSlug('-foo- bar -baz-').should.eql('foo-bar-baz'); | ||
getSlug('--foo- bar -baz---').should.eql('foo-bar-baz'); | ||
getSlug('---foo- bar -baz---').should.eql('foo-bar-baz'); | ||
getSlug('-foo- bar -baz-') | ||
.should.eql('foo-bar-baz'); | ||
getSlug('--foo- bar -baz---') | ||
.should.eql('foo-bar-baz'); | ||
getSlug('---foo- bar -baz---') | ||
.should.eql('foo-bar-baz'); | ||
@@ -42,5 +48,6 @@ done(); | ||
it('should remove multple separators', function(done) { | ||
it('should remove multple separators', function (done) { | ||
getSlug('foo- bar -baz').should.eql('foo-bar-baz'); | ||
getSlug('foo- bar -baz') | ||
.should.eql('foo-bar-baz'); | ||
@@ -50,7 +57,9 @@ done(); | ||
it('should remove non-base64 characters', function(done) { | ||
it('should remove non-base64 characters', function (done) { | ||
var nonBase64 = ['[', ']', ',', '*', '+', '~', '.', '(', ')', '\'', '"', '!', ':', '@']; | ||
for (var i = 0; i < nonBase64.length; i++) { | ||
getSlug("foo " + nonBase64[i] + " bar baz").should.eql("foo-bar-baz"); | ||
getSlug("foo " + nonBase64[i] + " bar baz") | ||
.should.eql("foo-bar-baz"); | ||
} | ||
@@ -61,5 +70,7 @@ | ||
it('should remove trailing separator', function(done) { | ||
it('should remove trailing separator', function (done) { | ||
getSlug('C\'est un beau titre qui ne laisse rien à désirer ! ').should.eql('c-est-un-beau-titre-qui-ne-laisse-rien-a-desirer'); | ||
getSlug('C\'est un beau titre qui ne laisse rien à désirer ! ') | ||
.should.eql( | ||
'c-est-un-beau-titre-qui-ne-laisse-rien-a-desirer'); | ||
@@ -69,19 +80,29 @@ done(); | ||
it('should handle whitespace after symbol', function(done) { | ||
it('should handle whitespace after symbol', function (done) { | ||
getSlug('∆299').should.eql('delta-299'); | ||
getSlug('∆world').should.eql('delta-world'); | ||
getSlug('∆-299').should.eql('delta-299'); | ||
getSlug('∆-world').should.eql('delta-world'); | ||
getSlug('∆299') | ||
.should.eql('delta-299'); | ||
getSlug('∆world') | ||
.should.eql('delta-world'); | ||
getSlug('∆-299') | ||
.should.eql('delta-299'); | ||
getSlug('∆-world') | ||
.should.eql('delta-world'); | ||
getSlug('(∆)299').should.eql('delta-299'); | ||
getSlug('(∆)299') | ||
.should.eql('delta-299'); | ||
getSlug('(∆)299', { | ||
mark: true | ||
}).should.eql('(delta)299'); | ||
}) | ||
.should.eql('(delta)299'); | ||
getSlug('∆299').should.eql('delta-299'); | ||
getSlug('∆world').should.eql('delta-world'); | ||
getSlug('∆299') | ||
.should.eql('delta-299'); | ||
getSlug('∆world') | ||
.should.eql('delta-world'); | ||
getSlug('Hello∆299').should.eql('hello-delta-299'); | ||
getSlug('299∆Hello').should.eql('299-delta-hello'); | ||
getSlug('Hello∆299') | ||
.should.eql('hello-delta-299'); | ||
getSlug('299∆Hello') | ||
.should.eql('299-delta-hello'); | ||
@@ -91,10 +112,16 @@ done(); | ||
it('should not fail if symbol at the end', function(done) { | ||
it('should not fail if symbol at the end', function (done) { | ||
getSlug('test &').should.eql('test-and'); | ||
getSlug('test & ').should.eql('test-and'); | ||
getSlug('test &', '_').should.eql('test_and'); | ||
getSlug('test ♥').should.eql('test-love'); | ||
getSlug('test ♥ ').should.eql('test-love'); | ||
getSlug('test ♥ ').should.eql('test-love'); | ||
getSlug('test &') | ||
.should.eql('test-and'); | ||
getSlug('test & ') | ||
.should.eql('test-and'); | ||
getSlug('test &', '_') | ||
.should.eql('test_and'); | ||
getSlug('test ♥') | ||
.should.eql('test-love'); | ||
getSlug('test ♥ ') | ||
.should.eql('test-love'); | ||
getSlug('test ♥ ') | ||
.should.eql('test-love'); | ||
@@ -101,0 +128,0 @@ done(); |
@@ -5,6 +5,6 @@ /* global describe,it */ | ||
describe('getSlug languages', function() { | ||
describe('getSlug languages', function () { | ||
'use strict'; | ||
it('should replace language specific symbols', function(done) { | ||
it('should replace language specific symbols', function (done) { | ||
@@ -98,58 +98,72 @@ var symbolMap = { | ||
Object.keys(symbolMap).forEach(function(l) { | ||
Object.keys(symbolMap) | ||
.forEach(function (l) { | ||
// console.log('\ncheck language: ' + l); | ||
// console.log('\ncheck language: ' + l); | ||
Object.keys(symbolMap[l]).forEach(function(s) { | ||
Object.keys(symbolMap[l]) | ||
.forEach(function (s) { | ||
var k = symbolMap[l][s]; | ||
var k = symbolMap[l][s]; | ||
// console.log('check symbol: ' + s); | ||
// console.log('check symbol: ' + s); | ||
getSlug('Foo ' + s + ' Bar', { | ||
lang: l, | ||
maintainCase: true | ||
}).should.eql('Foo-' + getSlug(k, { | ||
maintainCase: true | ||
}) + '-Bar'); | ||
getSlug('Foo ' + s + ' Bar', { | ||
lang: l, | ||
maintainCase: true | ||
}) | ||
.should.eql('Foo-' + getSlug(k, { | ||
maintainCase: true | ||
}) + '-Bar'); | ||
getSlug('Foo ' + s + ' Bar', { | ||
lang: l | ||
}).should.eql('foo-' + getSlug(k) + '-bar'); | ||
getSlug('Foo ' + s + ' Bar', { | ||
lang: l | ||
}) | ||
.should.eql('foo-' + getSlug(k) + | ||
'-bar'); | ||
}); | ||
}); | ||
}); | ||
getSlug('EN Foo & Bar ') | ||
.should.eql('en-foo-and-bar'); | ||
getSlug('EN Foo & Bar ').should.eql('en-foo-and-bar'); | ||
getSlug('EN Foo & Bar ', { | ||
lang: "en" | ||
}).should.eql('en-foo-and-bar'); | ||
}) | ||
.should.eql('en-foo-and-bar'); | ||
getSlug('de Foo & Bar ', { | ||
lang: "de" | ||
}).should.eql('de-foo-und-bar'); | ||
}) | ||
.should.eql('de-foo-und-bar'); | ||
getSlug('True Foo & Bar ', { | ||
lang: true | ||
}).should.eql('true-foo-bar'); | ||
}) | ||
.should.eql('true-foo-bar'); | ||
getSlug('False Foo & Bar ', { | ||
lang: false | ||
}).should.eql('false-foo-bar'); | ||
}) | ||
.should.eql('false-foo-bar'); | ||
getSlug('xx Foo & Bar ', { | ||
lang: "xx" | ||
}).should.eql('xx-foo-and-bar'); | ||
}) | ||
.should.eql('xx-foo-and-bar'); | ||
getSlug('obj Foo & Bar ', { | ||
lang: {} | ||
}).should.eql('obj-foo-and-bar'); | ||
}) | ||
.should.eql('obj-foo-and-bar'); | ||
getSlug('array Foo & Bar ', { | ||
lang: [] | ||
}).should.eql('array-foo-and-bar'); | ||
}) | ||
.should.eql('array-foo-and-bar'); | ||
getSlug('null Foo & Bar ', { | ||
lang: null | ||
}).should.eql('null-foo-and-bar'); | ||
}) | ||
.should.eql('null-foo-and-bar'); | ||
@@ -156,0 +170,0 @@ done(); |
@@ -5,22 +5,26 @@ /* global describe,it */ | ||
describe('getSlug maintainCase', function() { | ||
describe('getSlug maintainCase', function () { | ||
'use strict'; | ||
it('should maintain case characters', function(done) { | ||
it('should maintain case characters', function (done) { | ||
getSlug('Foo, Bar Baz', { | ||
maintainCase: true | ||
}).should.eql('Foo-Bar-Baz'); | ||
}) | ||
.should.eql('Foo-Bar-Baz'); | ||
getSlug('Foo- Bar Baz', { | ||
maintainCase: true | ||
}).should.eql('Foo-Bar-Baz'); | ||
}) | ||
.should.eql('Foo-Bar-Baz'); | ||
getSlug('Foo] Bar Baz', { | ||
maintainCase: true | ||
}).should.eql('Foo-Bar-Baz'); | ||
}) | ||
.should.eql('Foo-Bar-Baz'); | ||
getSlug('Foo > Bar ♥ Baz', { | ||
maintainCase: true | ||
}).should.eql('Foo-greater-than-Bar-love-Baz'); | ||
}) | ||
.should.eql('Foo-greater-than-Bar-love-Baz'); | ||
@@ -27,0 +31,0 @@ done(); |
@@ -5,12 +5,15 @@ /* global describe,it */ | ||
describe('getSlug rfc3986', function() { | ||
describe('getSlug rfc3986', function () { | ||
'use strict'; | ||
it('"uric" characters allowed', function(done) { | ||
it('"uric" characters allowed', function (done) { | ||
var chars = [';', '?', ':', '@', '&', '=', '+', ',', '/']; | ||
for (var i = 0; i < chars.length; i++) { | ||
getSlug("foo " + chars[i] + " bar baz", { | ||
uric: true | ||
}).should.eql("foo-" + chars[i] + "-bar-baz"); | ||
}) | ||
.should.eql("foo-" + chars[i] + "-bar-baz"); | ||
} | ||
@@ -21,3 +24,3 @@ | ||
it('"uricNoSlash" characters allowed', function(done) { | ||
it('"uricNoSlash" characters allowed', function (done) { | ||
@@ -29,3 +32,4 @@ var chars = [';', '?', ':', '@', '&', '=', '+', ',']; | ||
uricNoSlash: true | ||
}).should.eql("foo-" + chars[i] + "-bar-baz"); | ||
}) | ||
.should.eql("foo-" + chars[i] + "-bar-baz"); | ||
} | ||
@@ -36,3 +40,3 @@ | ||
it('"mark" characters allowed', function(done) { | ||
it('"mark" characters allowed', function (done) { | ||
@@ -44,3 +48,4 @@ var chars = ['.', '!', '~', '*', '\'', '(', ')']; | ||
mark: true | ||
}).should.eql("foo-" + chars[i] + "-bar-baz"); | ||
}) | ||
.should.eql("foo-" + chars[i] + "-bar-baz"); | ||
} | ||
@@ -51,3 +56,3 @@ | ||
it('"uric" characters allowed, separator ";"', function(done) { | ||
it('"uric" characters allowed, separator ";"', function (done) { | ||
@@ -60,3 +65,4 @@ var chars = ['?', ':', '@', '&', '=', '+', ',', '/']; | ||
separator: ';' | ||
}).should.eql("foo;" + chars[i] + ";bar;baz"); | ||
}) | ||
.should.eql("foo;" + chars[i] + ";bar;baz"); | ||
} | ||
@@ -67,3 +73,3 @@ | ||
it('"uric" characters allowed, separator ";" included in input string', function(done) { | ||
it('"uric" characters allowed, separator ";" included in input string', function (done) { | ||
@@ -73,3 +79,4 @@ getSlug("foo ; bar baz", { | ||
separator: ';' | ||
}).should.eql("foo;bar;baz"); | ||
}) | ||
.should.eql("foo;bar;baz"); | ||
@@ -79,3 +86,3 @@ done(); | ||
it('"uricNoSlash" characters allowed, separator ";"', function(done) { | ||
it('"uricNoSlash" characters allowed, separator ";"', function (done) { | ||
@@ -88,3 +95,4 @@ var chars = ['?', ':', '@', '&', '=', '+', ',']; | ||
separator: ';' | ||
}).should.eql("foo;" + chars[i] + ";bar;baz"); | ||
}) | ||
.should.eql("foo;" + chars[i] + ";bar;baz"); | ||
} | ||
@@ -95,3 +103,3 @@ | ||
it('"uricNoSlash" characters allowed, separator ";" included in input string', function(done) { | ||
it('"uricNoSlash" characters allowed, separator ";" included in input string', function (done) { | ||
@@ -101,3 +109,4 @@ getSlug("foo ; bar baz", { | ||
separator: ';' | ||
}).should.eql("foo;bar;baz"); | ||
}) | ||
.should.eql("foo;bar;baz"); | ||
@@ -107,3 +116,3 @@ done(); | ||
it('"mark" characters allowed, separator "."', function(done) { | ||
it('"mark" characters allowed, separator "."', function (done) { | ||
@@ -116,3 +125,4 @@ var chars = ['!', '~', '*', '\'', '(', ')']; | ||
separator: '.' | ||
}).should.eql("foo." + chars[i] + ".bar.baz"); | ||
}) | ||
.should.eql("foo." + chars[i] + ".bar.baz"); | ||
} | ||
@@ -123,3 +133,3 @@ | ||
it('"mark" characters allowed, separator "." included in input string', function(done) { | ||
it('"mark" characters allowed, separator "." included in input string', function (done) { | ||
@@ -129,3 +139,4 @@ getSlug("foo . bar baz", { | ||
separator: '.' | ||
}).should.eql("foo.bar.baz"); | ||
}) | ||
.should.eql("foo.bar.baz"); | ||
@@ -132,0 +143,0 @@ done(); |
@@ -5,24 +5,30 @@ /* global describe,it */ | ||
describe('getSlug separator', function() { | ||
describe('getSlug separator', function () { | ||
'use strict'; | ||
it('should separate with non-whitespace', function(done) { | ||
it('should separate with non-whitespace', function (done) { | ||
getSlug('Foo Bar Baz', { | ||
separator: '-' | ||
}).should.eql('foo-bar-baz'); | ||
}) | ||
.should.eql('foo-bar-baz'); | ||
getSlug('Foo Bar Baz', { | ||
separator: '*' | ||
}).should.eql('foo*bar*baz'); | ||
}) | ||
.should.eql('foo*bar*baz'); | ||
getSlug('Foo Bar Baz', { | ||
separator: '_' | ||
}).should.eql('foo_bar_baz'); | ||
}) | ||
.should.eql('foo_bar_baz'); | ||
getSlug('Foo Bar Baz', '-').should.eql('foo-bar-baz'); | ||
getSlug('Foo Bar Baz', '-') | ||
.should.eql('foo-bar-baz'); | ||
getSlug('Foo Bar Baz', '*').should.eql('foo*bar*baz'); | ||
getSlug('Foo Bar Baz', '*') | ||
.should.eql('foo*bar*baz'); | ||
getSlug('Foo Bar Baz', '_').should.eql('foo_bar_baz'); | ||
getSlug('Foo Bar Baz', '_') | ||
.should.eql('foo_bar_baz'); | ||
@@ -33,21 +39,27 @@ done(); | ||
it('should separate with non-whitespace, with trailing spaces', function(done) { | ||
it('should separate with non-whitespace, with trailing spaces', function (done) { | ||
getSlug(' Foo Bar Baz ', { | ||
separator: '-' | ||
}).should.eql('foo-bar-baz'); | ||
}) | ||
.should.eql('foo-bar-baz'); | ||
getSlug(' Foo Bar Baz ', { | ||
separator: '*' | ||
}).should.eql('foo*bar*baz'); | ||
}) | ||
.should.eql('foo*bar*baz'); | ||
getSlug(' Foo Bar Baz ', { | ||
separator: '_' | ||
}).should.eql('foo_bar_baz'); | ||
}) | ||
.should.eql('foo_bar_baz'); | ||
getSlug(' Foo Bar Baz ', '-').should.eql('foo-bar-baz'); | ||
getSlug(' Foo Bar Baz ', '-') | ||
.should.eql('foo-bar-baz'); | ||
getSlug(' Foo Bar Baz ', '*').should.eql('foo*bar*baz'); | ||
getSlug(' Foo Bar Baz ', '*') | ||
.should.eql('foo*bar*baz'); | ||
getSlug(' Foo Bar Baz ', '_').should.eql('foo_bar_baz'); | ||
getSlug(' Foo Bar Baz ', '_') | ||
.should.eql('foo_bar_baz'); | ||
@@ -58,21 +70,27 @@ done(); | ||
it('should separate with trailing separator "-"', function(done) { | ||
it('should separate with trailing separator "-"', function (done) { | ||
getSlug('-Foo Bar Baz-', { | ||
separator: '-' | ||
}).should.eql('foo-bar-baz'); | ||
}) | ||
.should.eql('foo-bar-baz'); | ||
getSlug('--Foo Bar Baz---', { | ||
separator: '-' | ||
}).should.eql('foo-bar-baz'); | ||
}) | ||
.should.eql('foo-bar-baz'); | ||
getSlug('---Foo Bar Baz---', { | ||
separator: '-' | ||
}).should.eql('foo-bar-baz'); | ||
}) | ||
.should.eql('foo-bar-baz'); | ||
getSlug('-Foo Bar Baz-', '-').should.eql('foo-bar-baz'); | ||
getSlug('-Foo Bar Baz-', '-') | ||
.should.eql('foo-bar-baz'); | ||
getSlug('--Foo Bar Baz---', '-').should.eql('foo-bar-baz'); | ||
getSlug('--Foo Bar Baz---', '-') | ||
.should.eql('foo-bar-baz'); | ||
getSlug('---Foo Bar Baz---', '-').should.eql('foo-bar-baz'); | ||
getSlug('---Foo Bar Baz---', '-') | ||
.should.eql('foo-bar-baz'); | ||
@@ -82,21 +100,27 @@ done(); | ||
it('should separate with trailing separator "*"', function(done) { | ||
it('should separate with trailing separator "*"', function (done) { | ||
getSlug('*Foo Bar Baz*', { | ||
separator: '*' | ||
}).should.eql('foo*bar*baz'); | ||
}) | ||
.should.eql('foo*bar*baz'); | ||
getSlug('**Foo Bar Baz**', { | ||
separator: '*' | ||
}).should.eql('foo*bar*baz'); | ||
}) | ||
.should.eql('foo*bar*baz'); | ||
getSlug('***Foo Bar Baz***', { | ||
separator: '*' | ||
}).should.eql('foo*bar*baz'); | ||
}) | ||
.should.eql('foo*bar*baz'); | ||
getSlug('*Foo Bar Baz*', '*').should.eql('foo*bar*baz'); | ||
getSlug('*Foo Bar Baz*', '*') | ||
.should.eql('foo*bar*baz'); | ||
getSlug('**Foo Bar Baz**', '*').should.eql('foo*bar*baz'); | ||
getSlug('**Foo Bar Baz**', '*') | ||
.should.eql('foo*bar*baz'); | ||
getSlug('***Foo Bar Baz***', '*').should.eql('foo*bar*baz'); | ||
getSlug('***Foo Bar Baz***', '*') | ||
.should.eql('foo*bar*baz'); | ||
@@ -107,21 +131,27 @@ done(); | ||
it('should separate with trailing separator "_"', function(done) { | ||
it('should separate with trailing separator "_"', function (done) { | ||
getSlug('_Foo Bar Baz_', { | ||
separator: '_' | ||
}).should.eql('foo_bar_baz'); | ||
}) | ||
.should.eql('foo_bar_baz'); | ||
getSlug('__Foo Bar Baz__', { | ||
separator: '_' | ||
}).should.eql('foo_bar_baz'); | ||
}) | ||
.should.eql('foo_bar_baz'); | ||
getSlug('___Foo Bar Baz___', { | ||
separator: '_' | ||
}).should.eql('foo_bar_baz'); | ||
}) | ||
.should.eql('foo_bar_baz'); | ||
getSlug('_Foo Bar Baz_', '_').should.eql('foo_bar_baz'); | ||
getSlug('_Foo Bar Baz_', '_') | ||
.should.eql('foo_bar_baz'); | ||
getSlug('__Foo Bar Baz__', '_').should.eql('foo_bar_baz'); | ||
getSlug('__Foo Bar Baz__', '_') | ||
.should.eql('foo_bar_baz'); | ||
getSlug('___Foo Bar Baz___', '_').should.eql('foo_bar_baz'); | ||
getSlug('___Foo Bar Baz___', '_') | ||
.should.eql('foo_bar_baz'); | ||
@@ -131,10 +161,14 @@ done(); | ||
it('should remove trailing separator "*"', function(done) { | ||
it('should remove trailing separator "*"', function (done) { | ||
getSlug(' C\'est un beau titre qui ne laisse rien à désirer !', { | ||
separator: '*' | ||
}).should.eql('c*est*un*beau*titre*qui*ne*laisse*rien*a*desirer'); | ||
}) | ||
.should.eql( | ||
'c*est*un*beau*titre*qui*ne*laisse*rien*a*desirer'); | ||
getSlug(' C\'est un beau titre qui ne laisse rien à désirer !', '*') | ||
.should.eql('c*est*un*beau*titre*qui*ne*laisse*rien*a*desirer'); | ||
getSlug(' C\'est un beau titre qui ne laisse rien à désirer !', | ||
'*') | ||
.should.eql( | ||
'c*est*un*beau*titre*qui*ne*laisse*rien*a*desirer'); | ||
@@ -145,5 +179,6 @@ done(); | ||
it('should return empty string because of non string input', function(done) { | ||
it('should return empty string because of non string input', function (done) { | ||
getSlug(true).should.eql(''); | ||
getSlug(true) | ||
.should.eql(''); | ||
@@ -150,0 +185,0 @@ done(); |
@@ -5,6 +5,6 @@ /* global describe,it */ | ||
describe('getSlug config combinations', function() { | ||
describe('getSlug config combinations', function () { | ||
'use strict'; | ||
it('should separate with configured character, with non-Base64 separator', function(done) { | ||
it('should separate with configured character, with non-Base64 separator', function (done) { | ||
@@ -14,3 +14,4 @@ getSlug('Foo, Bar Baz', { | ||
maintainCase: false | ||
}).should.eql('foo*bar*baz'); | ||
}) | ||
.should.eql('foo*bar*baz'); | ||
@@ -20,3 +21,4 @@ getSlug('Foo- Bar Baz', { | ||
maintainCase: false | ||
}).should.eql('foo-*bar*baz'); | ||
}) | ||
.should.eql('foo-*bar*baz'); | ||
@@ -26,3 +28,4 @@ getSlug('Foo] Bar Baz', { | ||
maintainCase: false | ||
}).should.eql('foo*bar*baz'); | ||
}) | ||
.should.eql('foo*bar*baz'); | ||
@@ -32,3 +35,3 @@ done(); | ||
it('should separate with configured character, with only Base64 characters allowed', function(done) { | ||
it('should separate with configured character, with only Base64 characters allowed', function (done) { | ||
@@ -38,3 +41,4 @@ getSlug('Foo, Bar Baz', { | ||
onlyBase64: true | ||
}).should.eql('foo_bar_baz'); | ||
}) | ||
.should.eql('foo_bar_baz'); | ||
@@ -44,3 +48,4 @@ getSlug('Foo- Bar Baz', { | ||
onlyBase64: true | ||
}).should.eql('foo-_bar_baz'); | ||
}) | ||
.should.eql('foo-_bar_baz'); | ||
@@ -50,3 +55,4 @@ getSlug('Foo] Bar Baz', { | ||
onlyBase64: true | ||
}).should.eql('foo_bar_baz'); | ||
}) | ||
.should.eql('foo_bar_baz'); | ||
@@ -56,3 +62,3 @@ done(); | ||
it('should separate with configured character, with smart trim', function(done) { | ||
it('should separate with configured character, with smart trim', function (done) { | ||
@@ -62,3 +68,4 @@ getSlug('Foobarbaz, Bar Baz', { | ||
truncate: 12 | ||
}).should.eql('foobarbaz'); | ||
}) | ||
.should.eql('foobarbaz'); | ||
@@ -68,3 +75,4 @@ getSlug('Foobarbaz, Bar Baz', { | ||
truncate: 15 | ||
}).should.eql('foobarbaz_bar'); | ||
}) | ||
.should.eql('foobarbaz_bar'); | ||
@@ -74,3 +82,4 @@ getSlug(' Foobarbaz, Bar Baz', { | ||
truncate: 15 | ||
}).should.eql('foobarbaz_bar'); | ||
}) | ||
.should.eql('foobarbaz_bar'); | ||
@@ -80,3 +89,4 @@ getSlug(' Foobarbaz, Bar Baz', { | ||
truncate: 15 | ||
}).should.eql('foobarbaz_bar'); | ||
}) | ||
.should.eql('foobarbaz_bar'); | ||
@@ -86,3 +96,3 @@ done(); | ||
it('should maintain case characters, with non-Base64 separator', function(done) { | ||
it('should maintain case characters, with non-Base64 separator', function (done) { | ||
@@ -92,3 +102,4 @@ getSlug('Foo, Bar Baz', { | ||
separator: '*' | ||
}).should.eql('Foo*Bar*Baz'); | ||
}) | ||
.should.eql('Foo*Bar*Baz'); | ||
@@ -98,3 +109,4 @@ getSlug('Foo- Bar Baz', { | ||
separator: '*' | ||
}).should.eql('Foo-*Bar*Baz'); | ||
}) | ||
.should.eql('Foo-*Bar*Baz'); | ||
@@ -104,3 +116,4 @@ getSlug('Foo] Bar Baz', { | ||
separator: '*' | ||
}).should.eql('Foo*Bar*Baz'); | ||
}) | ||
.should.eql('Foo*Bar*Baz'); | ||
@@ -110,3 +123,3 @@ done(); | ||
it('should maintain case characters, with only Base64 characters allowed', function(done) { | ||
it('should maintain case characters, with only Base64 characters allowed', function (done) { | ||
@@ -118,3 +131,4 @@ getSlug('Foo, Bar Baz', { | ||
mark: false | ||
}).should.eql('Foo-Bar-Baz'); | ||
}) | ||
.should.eql('Foo-Bar-Baz'); | ||
@@ -126,3 +140,4 @@ getSlug('Foo- Bar Baz', { | ||
mark: false | ||
}).should.eql('Foo-Bar-Baz'); | ||
}) | ||
.should.eql('Foo-Bar-Baz'); | ||
@@ -134,3 +149,4 @@ getSlug('Foo] Bar Baz', { | ||
mark: false | ||
}).should.eql('Foo-Bar-Baz'); | ||
}) | ||
.should.eql('Foo-Bar-Baz'); | ||
@@ -140,3 +156,3 @@ done(); | ||
it('should maintain case characters, with smart trim', function(done) { | ||
it('should maintain case characters, with smart trim', function (done) { | ||
@@ -146,3 +162,4 @@ getSlug('Foobarbaz, Bar Baz', { | ||
truncate: 12 | ||
}).should.eql('Foobarbaz'); | ||
}) | ||
.should.eql('Foobarbaz'); | ||
@@ -152,3 +169,4 @@ getSlug('Foobarbaz, Bar Baz', { | ||
truncate: 15 | ||
}).should.eql('Foobarbaz-Bar'); | ||
}) | ||
.should.eql('Foobarbaz-Bar'); | ||
@@ -158,3 +176,4 @@ getSlug(' Foobarbaz, Bar Baz', { | ||
truncate: 15 | ||
}).should.eql('Foobarbaz-Bar'); | ||
}) | ||
.should.eql('Foobarbaz-Bar'); | ||
@@ -164,3 +183,4 @@ getSlug(' Foobarbaz, Bar Baz', { | ||
truncate: 15 | ||
}).should.eql('Foobarbaz-Bar'); | ||
}) | ||
.should.eql('Foobarbaz-Bar'); | ||
@@ -170,3 +190,3 @@ done(); | ||
it('should prefer Base64 characters only', function(done) { | ||
it('should prefer Base64 characters only', function (done) { | ||
@@ -177,3 +197,4 @@ getSlug('Foo, Bar Baz', { | ||
mark: false | ||
}).should.eql('foo-bar-baz'); | ||
}) | ||
.should.eql('foo-bar-baz'); | ||
@@ -184,3 +205,4 @@ getSlug('Foo- Bar Baz', { | ||
mark: false | ||
}).should.eql('foo-bar-baz'); | ||
}) | ||
.should.eql('foo-bar-baz'); | ||
@@ -191,3 +213,4 @@ getSlug('Foo] Bar Baz', { | ||
mark: false | ||
}).should.eql('foo-bar-baz'); | ||
}) | ||
.should.eql('foo-bar-baz'); | ||
@@ -198,3 +221,4 @@ getSlug('Foo* Bar Baz', { | ||
mark: false | ||
}).should.eql('foo-bar-baz'); | ||
}) | ||
.should.eql('foo-bar-baz'); | ||
@@ -201,0 +225,0 @@ done(); |
@@ -5,36 +5,44 @@ /* global describe,it */ | ||
describe('getSlug symbols', function() { | ||
describe('getSlug symbols', function () { | ||
'use strict'; | ||
it('should convert symbols', function(done) { | ||
it('should convert symbols', function (done) { | ||
getSlug('Foo & Bar | Baz').should.eql('foo-and-bar-or-baz'); | ||
getSlug('Foo & Bar | Baz') | ||
.should.eql('foo-and-bar-or-baz'); | ||
getSlug('Foo & Bar | Baz', { | ||
lang: 'en' | ||
}).should.eql('foo-and-bar-or-baz'); | ||
}) | ||
.should.eql('foo-and-bar-or-baz'); | ||
getSlug('Foo & Bar | Baz', { | ||
lang: 'de' | ||
}).should.eql('foo-und-bar-oder-baz'); | ||
}) | ||
.should.eql('foo-und-bar-oder-baz'); | ||
getSlug('Foo & Bar | Baz', { | ||
lang: 'fr' | ||
}).should.eql('foo-et-bar-ou-baz'); | ||
}) | ||
.should.eql('foo-et-bar-ou-baz'); | ||
getSlug('Foo & Bar | Baz', { | ||
lang: 'es' | ||
}).should.eql('foo-y-bar-u-baz'); | ||
}) | ||
.should.eql('foo-y-bar-u-baz'); | ||
getSlug('Foo & Bar | Baz', { | ||
lang: 'ru' | ||
}).should.eql('foo-i-bar-ili-baz'); | ||
}) | ||
.should.eql('foo-i-bar-ili-baz'); | ||
getSlug('Foo & Bar | Baz', { | ||
lang: 'cz' | ||
}).should.eql('foo-a-bar-nebo-baz'); | ||
}) | ||
.should.eql('foo-a-bar-nebo-baz'); | ||
getSlug('Foo & Bar | Baz', { | ||
lang: 'sk' | ||
}).should.eql('foo-a-bar-alebo-baz'); | ||
}) | ||
.should.eql('foo-a-bar-alebo-baz'); | ||
@@ -44,79 +52,96 @@ done(); | ||
it('should not convert symbols with uric flag true', function(done) { | ||
it('should not convert symbols with uric flag true', function (done) { | ||
getSlug('Foo & Bar | Baz', { | ||
uric: true | ||
}).should.eql('foo-&-bar-or-baz'); | ||
}) | ||
.should.eql('foo-&-bar-or-baz'); | ||
getSlug('Foo & Bar | Baz', { | ||
lang: 'en', | ||
uric: true | ||
}).should.eql('foo-&-bar-or-baz'); | ||
}) | ||
.should.eql('foo-&-bar-or-baz'); | ||
getSlug('Foo & Bar | Baz', { | ||
lang: 'de', | ||
uric: true | ||
}).should.eql('foo-&-bar-oder-baz'); | ||
}) | ||
.should.eql('foo-&-bar-oder-baz'); | ||
getSlug('Foo & Bar | Baz', { | ||
lang: 'fr', | ||
uric: true | ||
}).should.eql('foo-&-bar-ou-baz'); | ||
}) | ||
.should.eql('foo-&-bar-ou-baz'); | ||
getSlug('Foo & Bar | Baz', { | ||
lang: 'es', | ||
uric: true | ||
}).should.eql('foo-&-bar-u-baz'); | ||
}) | ||
.should.eql('foo-&-bar-u-baz'); | ||
getSlug('Foo & Bar | Baz', { | ||
lang: 'ru', | ||
uric: true | ||
}).should.eql('foo-&-bar-ili-baz'); | ||
}) | ||
.should.eql('foo-&-bar-ili-baz'); | ||
getSlug('Foo & Bar | Baz', { | ||
lang: 'cz', | ||
uric: true | ||
}).should.eql('foo-&-bar-nebo-baz'); | ||
}) | ||
.should.eql('foo-&-bar-nebo-baz'); | ||
getSlug('Foo & Bar | Baz', { | ||
lang: 'sk', | ||
uric: true | ||
}).should.eql('foo-&-bar-alebo-baz'); | ||
}) | ||
.should.eql('foo-&-bar-alebo-baz'); | ||
done(); | ||
}); | ||
it('should not convert symbols with uricNoSlash flag true', function(done) { | ||
it('should not convert symbols with uricNoSlash flag true', function (done) { | ||
getSlug('Foo & Bar | Baz', { | ||
uricNoSlash: true | ||
}).should.eql('foo-&-bar-or-baz'); | ||
}) | ||
.should.eql('foo-&-bar-or-baz'); | ||
getSlug('Foo & Bar | Baz', { | ||
lang: 'en', | ||
uricNoSlash: true | ||
}).should.eql('foo-&-bar-or-baz'); | ||
}) | ||
.should.eql('foo-&-bar-or-baz'); | ||
getSlug('Foo & Bar | Baz', { | ||
lang: 'de', | ||
uricNoSlash: true | ||
}).should.eql('foo-&-bar-oder-baz'); | ||
}) | ||
.should.eql('foo-&-bar-oder-baz'); | ||
getSlug('Foo & Bar | Baz', { | ||
lang: 'fr', | ||
uricNoSlash: true | ||
}).should.eql('foo-&-bar-ou-baz'); | ||
}) | ||
.should.eql('foo-&-bar-ou-baz'); | ||
getSlug('Foo & Bar | Baz', { | ||
lang: 'es', | ||
uricNoSlash: true | ||
}).should.eql('foo-&-bar-u-baz'); | ||
}) | ||
.should.eql('foo-&-bar-u-baz'); | ||
getSlug('Foo & Bar | Baz', { | ||
lang: 'ru', | ||
uricNoSlash: true | ||
}).should.eql('foo-&-bar-ili-baz'); | ||
}) | ||
.should.eql('foo-&-bar-ili-baz'); | ||
getSlug('Foo & Bar | Baz', { | ||
lang: 'cz', | ||
uricNoSlash: true | ||
}).should.eql('foo-&-bar-nebo-baz'); | ||
}) | ||
.should.eql('foo-&-bar-nebo-baz'); | ||
getSlug('Foo & Bar | Baz', { | ||
lang: 'sk', | ||
uricNoSlash: true | ||
}).should.eql('foo-&-bar-alebo-baz'); | ||
}) | ||
.should.eql('foo-&-bar-alebo-baz'); | ||
done(); | ||
}); | ||
it('should not convert symbols with mark flag true', function(done) { | ||
it('should not convert symbols with mark flag true', function (done) { | ||
getSlug('Foo (Bar) . Baz', { | ||
mark: true | ||
}).should.eql('foo-(bar)-.-baz'); | ||
}) | ||
.should.eql('foo-(bar)-.-baz'); | ||
@@ -126,3 +151,4 @@ getSlug('Foo (Bar) . Baz', { | ||
mark: true | ||
}).should.eql('foo-(bar)-.-baz'); | ||
}) | ||
.should.eql('foo-(bar)-.-baz'); | ||
@@ -132,3 +158,4 @@ getSlug('Foo (Bar) . Baz', { | ||
mark: true | ||
}).should.eql('foo-(bar)-.-baz'); | ||
}) | ||
.should.eql('foo-(bar)-.-baz'); | ||
@@ -138,3 +165,4 @@ getSlug('Foo (Bar) . Baz', { | ||
mark: true | ||
}).should.eql('foo-(bar)-.-baz'); | ||
}) | ||
.should.eql('foo-(bar)-.-baz'); | ||
@@ -144,3 +172,4 @@ getSlug('Foo (Bar) . Baz', { | ||
mark: true | ||
}).should.eql('foo-(bar)-.-baz'); | ||
}) | ||
.should.eql('foo-(bar)-.-baz'); | ||
@@ -150,3 +179,4 @@ getSlug('Foo (Bar) . Baz', { | ||
mark: true | ||
}).should.eql('foo-(bar)-.-baz'); | ||
}) | ||
.should.eql('foo-(bar)-.-baz'); | ||
@@ -156,3 +186,4 @@ getSlug('Foo (Bar) . Baz', { | ||
mark: true | ||
}).should.eql('foo-(bar)-.-baz'); | ||
}) | ||
.should.eql('foo-(bar)-.-baz'); | ||
@@ -162,3 +193,4 @@ getSlug('Foo (Bar) . Baz', { | ||
mark: true | ||
}).should.eql('foo-(bar)-.-baz'); | ||
}) | ||
.should.eql('foo-(bar)-.-baz'); | ||
@@ -169,3 +201,3 @@ done(); | ||
it('should convert symbols with flags true', function(done) { | ||
it('should convert symbols with flags true', function (done) { | ||
@@ -177,3 +209,4 @@ getSlug('Foo (♥) ; Baz=Bar', { | ||
mark: true | ||
}).should.eql('foo-(love)-;-baz=bar'); | ||
}) | ||
.should.eql('foo-(love)-;-baz=bar'); | ||
@@ -185,3 +218,4 @@ getSlug('Foo (♥) ; Baz=Bar', { | ||
mark: true | ||
}).should.eql('foo-(liebe)-;-baz=bar'); | ||
}) | ||
.should.eql('foo-(liebe)-;-baz=bar'); | ||
@@ -193,3 +227,4 @@ getSlug('Foo (♥) ; Baz=Bar', { | ||
mark: true | ||
}).should.eql('foo-(amour)-;-baz=bar'); | ||
}) | ||
.should.eql('foo-(amour)-;-baz=bar'); | ||
@@ -201,3 +236,4 @@ getSlug('Foo (♥) ; Baz=Bar', { | ||
mark: true | ||
}).should.eql('foo-(amor)-;-baz=bar'); | ||
}) | ||
.should.eql('foo-(amor)-;-baz=bar'); | ||
@@ -209,3 +245,4 @@ getSlug('Foo (♥) ; Baz=Bar', { | ||
mark: true | ||
}).should.eql('foo-(lubov)-;-baz=bar'); | ||
}) | ||
.should.eql('foo-(lubov)-;-baz=bar'); | ||
@@ -217,3 +254,4 @@ getSlug('Foo (♥) ; Baz=Bar', { | ||
mark: true | ||
}).should.eql('foo-(laska)-;-baz=bar'); | ||
}) | ||
.should.eql('foo-(laska)-;-baz=bar'); | ||
@@ -225,3 +263,4 @@ getSlug('Foo (♥) ; Baz=Bar', { | ||
mark: true | ||
}).should.eql('foo-(laska)-;-baz=bar'); | ||
}) | ||
.should.eql('foo-(laska)-;-baz=bar'); | ||
@@ -234,3 +273,6 @@ getSlug(' Sch(* )ner (♥)Ti♥tel ♥läßt grüßen!? Bel♥♥ été !', { | ||
maintainCase: true | ||
}).should.eql('Sch(*-)ner-(love)Ti-love-tel-love-laesst-gruessen!?-Bel-love-love-ete-!'); | ||
}) | ||
.should.eql( | ||
'Sch(*-)ner-(love)Ti-love-tel-love-laesst-gruessen!?-Bel-love-love-ete-!' | ||
); | ||
@@ -240,7 +282,8 @@ done(); | ||
it('should replace symbols (de)', function(done) { | ||
it('should replace symbols (de)', function (done) { | ||
getSlug('Äpfel & Birnen', { | ||
lang: 'de' | ||
}).should.eql('aepfel-und-birnen'); | ||
}) | ||
.should.eql('aepfel-und-birnen'); | ||
@@ -250,3 +293,4 @@ getSlug('ÄÖÜäöüß', { | ||
maintainCase: true | ||
}).should.eql('AeOeUeaeoeuess'); | ||
}) | ||
.should.eql('AeOeUeaeoeuess'); | ||
@@ -256,11 +300,19 @@ done(); | ||
it('should replace chars by cz language standards', function(done) { | ||
getSlug('AaÁáBbCcČčDdĎďEeÉéĚěFfGgHhChchIiÍíJjKkLlMmNnŇňOoÓóPpQqRrŘřSsŠšTtŤťUuÚúŮůVvWwXxYyÝýZzŽž', { | ||
lang: 'cz' | ||
}).should.eql('aaaabbccccddddeeeeeeffgghhchchiiiijjkkllmmnnnnooooppqqrrrrssssttttuuuuuuvvwwxxyyyyzzzz'); | ||
it('should replace chars by cz language standards', function (done) { | ||
getSlug( | ||
'AaÁáBbCcČčDdĎďEeÉéĚěFfGgHhChchIiÍíJjKkLlMmNnŇňOoÓóPpQqRrŘřSsŠšTtŤťUuÚúŮůVvWwXxYyÝýZzŽž', { | ||
lang: 'cz' | ||
}) | ||
.should.eql( | ||
'aaaabbccccddddeeeeeeffgghhchchiiiijjkkllmmnnnnooooppqqrrrrssssttttuuuuuuvvwwxxyyyyzzzz' | ||
); | ||
getSlug('AaÁáBbCcČčDdĎďEeÉéĚěFfGgHhChchIiÍíJjKkLlMmNnŇňOoÓóPpQqRrŘřSsŠšTtŤťUuÚúŮůVvWwXxYyÝýZzŽž', { | ||
lang: 'cz', | ||
maintainCase: true | ||
}).should.eql('AaAaBbCcCcDdDdEeEeEeFfGgHhChchIiIiJjKkLlMmNnNnOoOoPpQqRrRrSsSsTtTtUuUuUuVvWwXxYyYyZzZz'); | ||
getSlug( | ||
'AaÁáBbCcČčDdĎďEeÉéĚěFfGgHhChchIiÍíJjKkLlMmNnŇňOoÓóPpQqRrŘřSsŠšTtŤťUuÚúŮůVvWwXxYyÝýZzŽž', { | ||
lang: 'cz', | ||
maintainCase: true | ||
}) | ||
.should.eql( | ||
'AaAaBbCcCcDdDdEeEeEeFfGgHhChchIiIiJjKkLlMmNnNnOoOoPpQqRrRrSsSsTtTtUuUuUuVvWwXxYyYyZzZz' | ||
); | ||
@@ -270,11 +322,19 @@ done(); | ||
it('should replace chars by sk language standards', function(done) { | ||
getSlug('AaÁaÄäBbCcČčDdĎďDzdzDždžEeÉéFfGgHhChchIiÍíJjKkLlĹ弾MmNnŇňOoÓóÔôPpQqRrŔŕSsŠšTtŤťUuÚúVvWwXxYyÝýZzŽž', { | ||
lang: 'sk' | ||
}).should.eql('aaaaaabbccccdddddzdzdzdzeeeeffgghhchchiiiijjkkllllllmmnnnnooooooppqqrrrrssssttttuuuuvvwwxxyyyyzzzz'); | ||
it('should replace chars by sk language standards', function (done) { | ||
getSlug( | ||
'AaÁaÄäBbCcČčDdĎďDzdzDždžEeÉéFfGgHhChchIiÍíJjKkLlĹ弾MmNnŇňOoÓóÔôPpQqRrŔŕSsŠšTtŤťUuÚúVvWwXxYyÝýZzŽž', { | ||
lang: 'sk' | ||
}) | ||
.should.eql( | ||
'aaaaaabbccccdddddzdzdzdzeeeeffgghhchchiiiijjkkllllllmmnnnnooooooppqqrrrrssssttttuuuuvvwwxxyyyyzzzz' | ||
); | ||
getSlug('AaÁaÄäBbCcČčDdĎďDzdzDždžEeÉéFfGgHhChchIiÍíJjKkLlĹ弾MmNnŇňOoÓóÔôPpQqRrŔŕSsŠšTtŤťUuÚúVvWwXxYyÝýZzŽž', { | ||
lang: 'sk', | ||
maintainCase: true | ||
}).should.eql('AaAaAaBbCcCcDdDdDzdzDzdzEeEeFfGgHhChchIiIiJjKkLlLlLlMmNnNnOoOoOoPpQqRrRrSsSsTtTtUuUuVvWwXxYyYyZzZz'); | ||
getSlug( | ||
'AaÁaÄäBbCcČčDdĎďDzdzDždžEeÉéFfGgHhChchIiÍíJjKkLlĹ弾MmNnŇňOoÓóÔôPpQqRrŔŕSsŠšTtŤťUuÚúVvWwXxYyÝýZzŽž', { | ||
lang: 'sk', | ||
maintainCase: true | ||
}) | ||
.should.eql( | ||
'AaAaAaBbCcCcDdDdDzdzDzdzEeEeFfGgHhChchIiIiJjKkLlLlLlMmNnNnOoOoOoPpQqRrRrSsSsTtTtUuUuVvWwXxYyYyZzZz' | ||
); | ||
@@ -284,7 +344,8 @@ done(); | ||
it('should ignore not available language param', function(done) { | ||
it('should ignore not available language param', function (done) { | ||
getSlug('Äpfel & Birnen', { | ||
lang: 'xx' | ||
}).should.eql('aepfel-and-birnen'); | ||
}) | ||
.should.eql('aepfel-and-birnen'); | ||
@@ -294,15 +355,18 @@ done(); | ||
it('should convert currency symbols to lowercase', function(done) { | ||
it('should convert currency symbols to lowercase', function (done) { | ||
getSlug('NEXUS4 only €199!', { | ||
maintainCase: false | ||
}).should.eql('nexus4-only-eur199'); | ||
}) | ||
.should.eql('nexus4-only-eur199'); | ||
getSlug('NEXUS4 only €299.93', { | ||
maintainCase: false | ||
}).should.eql('nexus4-only-eur299-93'); | ||
}) | ||
.should.eql('nexus4-only-eur299-93'); | ||
getSlug('NEXUS4 only 円399.73', { | ||
maintainCase: false | ||
}).should.eql('nexus4-only-yen399-73'); | ||
}) | ||
.should.eql('nexus4-only-yen399-73'); | ||
@@ -312,15 +376,18 @@ done(); | ||
it('should convert currency symbols to uppercase', function(done) { | ||
it('should convert currency symbols to uppercase', function (done) { | ||
getSlug('NEXUS4 only €199!', { | ||
maintainCase: true | ||
}).should.eql('NEXUS4-only-EUR199'); | ||
}) | ||
.should.eql('NEXUS4-only-EUR199'); | ||
getSlug('NEXUS4 only €299.93', { | ||
maintainCase: true | ||
}).should.eql('NEXUS4-only-EUR299-93'); | ||
}) | ||
.should.eql('NEXUS4-only-EUR299-93'); | ||
getSlug('NEXUS4 only 円399.73', { | ||
maintainCase: true | ||
}).should.eql('NEXUS4-only-YEN399-73'); | ||
}) | ||
.should.eql('NEXUS4-only-YEN399-73'); | ||
@@ -327,0 +394,0 @@ done(); |
@@ -5,18 +5,21 @@ /* global describe,it */ | ||
describe('getSlug titleCase', function() { | ||
describe('getSlug titleCase', function () { | ||
'use strict'; | ||
it('should title-case the characters', function(done) { | ||
it('should title-case the characters', function (done) { | ||
getSlug('This is big foo', { | ||
titleCase: true | ||
}).should.eql('This-Is-Big-Foo'); | ||
}) | ||
.should.eql('This-Is-Big-Foo'); | ||
getSlug('This is Big foo', { | ||
titleCase: true | ||
}).should.eql('This-Is-Big-Foo'); | ||
}) | ||
.should.eql('This-Is-Big-Foo'); | ||
getSlug('Don\'t drink and drive', { | ||
titleCase: true | ||
}).should.eql('Don-t-Drink-And-Drive'); | ||
}) | ||
.should.eql('Don-t-Drink-And-Drive'); | ||
@@ -26,23 +29,28 @@ done(); | ||
it('should title-case the characters with custom array', function(done) { | ||
it('should title-case the characters with custom array', function (done) { | ||
getSlug('This is yet foo and bar', { | ||
titleCase: ['and', 'yet'] | ||
}).should.eql('This-Is-yet-Foo-and-Bar'); | ||
}) | ||
.should.eql('This-Is-yet-Foo-and-Bar'); | ||
getSlug('This is a foo and an angry bird', { | ||
titleCase: ['a', 'an', 'and'] | ||
}).should.eql('This-Is-a-Foo-and-an-Angry-Bird'); | ||
}) | ||
.should.eql('This-Is-a-Foo-and-an-Angry-Bird'); | ||
getSlug('This is a foo and an angry bird show', { | ||
titleCase: ['a'] | ||
}).should.eql('This-Is-a-Foo-And-An-Angry-Bird-Show'); | ||
}) | ||
.should.eql('This-Is-a-Foo-And-An-Angry-Bird-Show'); | ||
getSlug('Don\'t drink and drive', { | ||
titleCase: ['and'] | ||
}).should.eql('Don-t-Drink-and-Drive'); | ||
}) | ||
.should.eql('Don-t-Drink-and-Drive'); | ||
getSlug('Don\'t drink and drive', { | ||
titleCase: {} | ||
}).should.eql('Don-t-Drink-And-Drive'); | ||
}) | ||
.should.eql('Don-t-Drink-And-Drive'); | ||
@@ -53,7 +61,9 @@ getSlug('Don\'t drink and drive', { | ||
} | ||
}).should.eql('Don-t-Drink-And-Drive'); | ||
}) | ||
.should.eql('Don-t-Drink-And-Drive'); | ||
getSlug('Don\'t drink and drive', { | ||
titleCase: 42 | ||
}).should.eql('Don-t-Drink-And-Drive'); | ||
}) | ||
.should.eql('Don-t-Drink-And-Drive'); | ||
@@ -60,0 +70,0 @@ done(); |
@@ -5,50 +5,61 @@ /* global describe,it */ | ||
describe('getSlug smart truncate', function() { | ||
describe('getSlug smart truncate', function () { | ||
'use strict'; | ||
it('should maintain case characters, with smart truncate', function(done) { | ||
it('should maintain case characters, with smart truncate', function (done) { | ||
getSlug('Foobarbaz, Bar Baz', { | ||
truncate: 12 | ||
}).should.eql('foobarbaz'); | ||
}) | ||
.should.eql('foobarbaz'); | ||
getSlug('Foobarbaz, Bar Baz', { | ||
truncate: 15 | ||
}).should.eql('foobarbaz-bar'); | ||
}) | ||
.should.eql('foobarbaz-bar'); | ||
getSlug(' Foobarbaz, Bar Baz', { | ||
truncate: 15 | ||
}).should.eql('foobarbaz-bar'); | ||
}) | ||
.should.eql('foobarbaz-bar'); | ||
getSlug(' Foobarbaz, Bar Baz', { | ||
truncate: 15 | ||
}).should.eql('foobarbaz-bar'); | ||
}) | ||
.should.eql('foobarbaz-bar'); | ||
getSlug('Foo Foo bar Zoo Bar Baz', { | ||
truncate: 15 | ||
}).should.eql('foo-foo-bar-zoo'); | ||
}) | ||
.should.eql('foo-foo-bar-zoo'); | ||
getSlug('Foo Foo bar ZooBar Baz', { | ||
truncate: 15 | ||
}).should.eql('foo-foo-bar'); | ||
}) | ||
.should.eql('foo-foo-bar'); | ||
getSlug('Foo Foo bar ZooBar Baz', { | ||
truncate: 15 | ||
}).should.eql('foo-foo-bar'); | ||
}) | ||
.should.eql('foo-foo-bar'); | ||
getSlug('Foo Foo Bar Bar', { | ||
truncate: "foo" | ||
}).should.eql('foo-foo-bar-bar'); | ||
}) | ||
.should.eql('foo-foo-bar-bar'); | ||
getSlug('Foo Foo Bar Bar', { | ||
truncate: false | ||
}).should.eql('foo-foo-bar-bar'); | ||
}) | ||
.should.eql('foo-foo-bar-bar'); | ||
getSlug('Foo Foo Bar Bar', { | ||
truncate: true | ||
}).should.eql('foo-foo-bar-bar'); | ||
}) | ||
.should.eql('foo-foo-bar-bar'); | ||
getSlug('a Foo', { | ||
truncate: true | ||
}).should.eql('a-foo'); | ||
}) | ||
.should.eql('a-foo'); | ||
@@ -55,0 +66,0 @@ done(); |
Sorry, the diff of this file is not supported yet
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
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
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
96559
2352
14
1