Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

speakingurl

Package Overview
Dependencies
Maintainers
1
Versions
79
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

speakingurl - npm Package Compare versions

Comparing version 1.0.0 to 1.1.0

2

bower.json
{
"name": "speakingurl",
"version": "1.0.0",
"version": "1.1.0",
"description": "Generate a slug – transliteration with a lot of options",

@@ -5,0 +5,0 @@ "main": "speakingurl.min.js",

Changelog
=========
- v1.1.0 custom config can be an array, all chars are added to allowed chars
- v1.0.0 fix #47; bumpup to semver ;-)
- v0.20.0 add support for hungarian #45

@@ -5,0 +7,0 @@ - v0.19.0 add support for burmese #44

@@ -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": "1.0.0",
"version": "1.1.0",
"keywords": [

@@ -8,0 +8,0 @@ "slug",

@@ -14,3 +14,3 @@ (function (root) {

var maintainCase = (typeof opts === 'object' && opts.maintainCase) || false;
var titleCase = (typeof opts === 'object' && opts.titleCase) ? opts.titleCase : false;
var titleCase;
var customReplacements = (typeof opts === 'object' && typeof opts.custom === 'object' && opts.custom) ? opts.custom : {};

@@ -41,10 +41,22 @@ var separator = (typeof opts === 'object' && opts.separator) || '-';

if (titleCase && typeof titleCase.length === "number" && Array.prototype.toString.call(titleCase)) {
// if titleCase config is an Array, rewrite to object format
if (typeof opts === 'object' && opts.titleCase && typeof opts.titleCase.length === "number" && Array.prototype.toString.call(opts.titleCase)) {
// custom config is an Array, rewrite to object format
titleCase.forEach(function (v) {
opts.titleCase.forEach(function (v) {
customReplacements[v + ""] = v + "";
});
titleCase = true;
} else {
titleCase = typeof opts === 'object' && !!opts.titleCase;
}
// if custom config is an Array, rewrite to object format
if (typeof opts === 'object' && opts.custom && typeof opts.custom.length === "number" && Array.prototype.toString.call(opts.custom)) {
opts.custom.forEach(function (v) {
customReplacements[v + ""] = v + "";
});
}
if (typeof input !== 'string') {

@@ -108,11 +120,2 @@ return '';

var isReplacedCustomChar = function (ch, customReplacements) {
for (var c in customReplacements) {
if (customReplacements[c] == ch) {
return true;
}
}
};
for (i = 0, l = input.length; i < l; i++) {

@@ -149,3 +152,3 @@

// end of string, put the whole meaningful word
if (i == l - 1) {
if (i === l - 1) {
ch = diatricMap[diatricString];

@@ -198,3 +201,3 @@ }

if (!maintainCase && !titleCase && !titleCase.length) {
if (!maintainCase && !titleCase) {
result = result.toLowerCase();

@@ -223,3 +226,8 @@ }

/**
* escape Chars
* @param {string} input string
*/
var escapeChars = function escapeChars(input) {
return input.replace(/[-\\^$*+?.()|[\]{}\/]/g, '\\$&');

@@ -229,2 +237,16 @@ };

/**
* check if the char is an already converted char from custom list
* @param {char} ch character to check
* @param {object} customReplacements custom translation map
*/
var isReplacedCustomChar = function (ch, customReplacements) {
for (var c in customReplacements) {
if (customReplacements[c] === ch) {
return true;
}
}
};
/**
* charMap

@@ -231,0 +253,0 @@ * @type {Object}

{
"name": "speakingurl",
"version": "1.0.0",
"version": "1.1.0",
"description": "Generate a slug – transliteration with a lot of options",

@@ -5,0 +5,0 @@ "homepage": "http://pid.github.io/speakingurl/",

@@ -55,3 +55,3 @@ SpeakingURL [![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) [![Gitter](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/pid/speakingurl?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge)

- available versions: http://cdnjs.com/libraries/speakingurl/
- use //cdnjs.cloudflare.com/ajax/libs/speakingurl/1.0.0/speakingurl.min.js
- use //cdnjs.cloudflare.com/ajax/libs/speakingurl/1.1.0/speakingurl.min.js

@@ -61,3 +61,3 @@ #### [CDN/maxcdn](https://www.maxcdn.com/)

- available versions: http://www.jsdelivr.com/#!speakingurl
- use //cdn.jsdelivr.net/speakingurl/1.0.0/speakingurl.min.js
- use //cdn.jsdelivr.net/speakingurl/1.1.0/speakingurl.min.js

@@ -86,3 +86,3 @@ Usage

- true -\> convert input string to title-case
- array -\> exclude words
- array -\> titlecase = true, but omit the words from in the array
- `truncate` {number} default: 0

@@ -98,4 +98,5 @@ - 0 -\> don't trim length

- true -\> additionally allow chars: "-", "\_", ".", "!", "~", "\*", "'", "(", ")"
- `custom` {object} default: {}
- custom map for translation, overwrites all i.e. { '&': '\#', '\*': ' star ' }
- `custom` {object|array} default: {}
- object -\> custom map for translation, overwrites all i.e. { '&': '\#', '\*': ' star ' }
- array -\> add chars to allowed charMap (see example)

@@ -131,3 +132,3 @@ - `options` {string} separator

separator: '_'
});
});
console.log(slug); // Output: schoener_titel_laesst_gruessen_bel_ete

@@ -137,46 +138,46 @@

uric: true
});
});
console.log(slug); // Output: schoener-titel-laesst-gruessen?-bel-ete
slug = getSlug("Schöner Titel läßt grüßen!? Bel été !", {
uricNoSlash: true
});
uricNoSlash: true
});
console.log(slug); // Output: schoener-titel-laesst-gruessen?-bel-ete
slug = getSlug("Schöner Titel läßt grüßen!? Bel été !", {
mark: true
});
mark: true
});
console.log(slug); // Output: schoener-titel-laesst-gruessen!-bel-ete-!
slug = getSlug("Schöner Titel läßt grüßen!? Bel été !", {
truncate: 20
});
truncate: 20
});
console.log(slug); // Output: schoener-titel
slug = getSlug("Schöner Titel läßt grüßen!? Bel été !", {
maintainCase: true
});
maintainCase: true
});
console.log(slug); // Output: Schoener-Titel-laesst-gruessen-Bel-ete
slug = getSlug("Äpfel & Birnen!", {
lang: 'de'
});
lang: 'de'
});
console.log(slug); // Output: aepfel-und-birnen
slug = getSlug("မြန်မာ သာဓက", {
lang: 'my'
});
lang: 'my'
});
console.log(slug); // Output: myanma-thadak
slug = getSlug("Apple & Pear!", {
lang: 'en' // lang: "en" is default, just to clarify
});
lang: 'en' // lang: "en" is default, just to clarify
});
console.log(slug); // Output: apple-and-pear
slug = getSlug('Foo & Bar * Baz', {
custom: {
'&': ' doo '
},
uric:true
});
custom: {
'&': ' doo '
},
uric:true
});
console.log(slug); // Output: foo-doo-bar-baz

@@ -188,17 +189,25 @@

slug = getSlug('Foo & Bar | (Baz) * Doo', {
custom: {
'*': 'Boo'
},
mark:true
});
custom: {
'*': 'Boo'
},
mark:true
});
console.log(slug); // Output: foo-and-bar-or-(baz)-boo-doo
slug = getSlug('Foo and Bar or Baz', {
custom: {
'and': 'und',
'or': ''
}
});
custom: {
'and': 'und',
'or': ''
}
});
console.log(slug); // Output: foo-und-bar-baz
slug = getSlug('[Knöpfe]', {
custom: [
'[',
']'
]
});
console.log(slug); // Output: [knoepfe]
slug = getSlug('NEXUS4 only $299');

@@ -208,19 +217,19 @@ console.log(slug); // Output: nexus-4-only-usd299

slug = getSlug('NEXUS4 only €299', {
maintainCase: true
});
maintainCase: true
});
console.log(slug); // Output: NEXUS-4-only-EUR299
slug = getSlug('Don\'t drink and drive', {
titleCase: true
});
titleCase: true
});
console.log(slug); // Output: Don-t-Drink-And-Drive
slug = getSlug('Don\'t drink and drive', {
titleCase: ['and']
});
titleCase: ['and']
});
console.log(slug); // Output: Don-t-Drink-and-Drive
slug = getSlug('Foo & Bar ♥ Foo < Bar', {
lang: false
});
lang: false
});
console.log(slug); // Output: foo-bar-foo-bar

@@ -237,5 +246,5 @@ ```

var options = {
maintainCase: true,
separator: '_'
};
maintainCase: true,
separator: '_'
};

@@ -254,8 +263,8 @@ var mySlug = require('speakingurl').createSlug(options);

var options = {
titleCase: [
"a","an","and","as","at","but",
"by","en","for","if","in","nor",
"of","on","or","per","the","to","vs"
]
};
titleCase: [
"a","an","and","as","at","but",
"by","en","for","if","in","nor",
"of","on","or","per","the","to","vs"
]
};

@@ -273,3 +282,3 @@ var mySlug = require('speakingurl').createSlug(options);

see[CHANGELOG.md](https://raw.github.com/pid/speakingurl/master/CHANGELOG.md)
see [CHANGELOG.md](https://raw.github.com/pid/speakingurl/master/CHANGELOG.md)

@@ -276,0 +285,0 @@ Tests

/**
* speakingurl
* @version v1.0.0
* @version v1.1.0
* @link http://pid.github.io/speakingurl/
* @license BSD
* @author Sascha Droste
*/!function(e){"use strict";var a=function(e,a){var n,s,c,g,m,h,d="object"==typeof a&&a.maintainCase||!1,f="object"==typeof a&&a.titleCase?a.titleCase:!1,y="object"==typeof a&&"object"==typeof a.custom&&a.custom?a.custom:{},p="object"==typeof a&&a.separator||"-",k="object"==typeof a&&+a.truncate>1&&a.truncate||!1,b="object"==typeof a&&a.uric||!1,A="object"==typeof a&&a.uricNoSlash||!1,j="object"==typeof a&&a.mark||!1,E="object"==typeof a&&a.lang&&l[a.lang]?l[a.lang]:"object"!=typeof a||a.lang!==!1&&a.lang!==!0?l.en:{},O="object"==typeof a&&a.lang&&r[a.lang]?r[a.lang]:"object"!=typeof a||a.lang!==!1&&a.lang!==!0?r.en:{},w=[";","?",":","@","&","=","+","$",",","/"],S=[";","?",":","@","&","=","+","$",","],v=[".","!","~","*","'","(",")"],U="",z="",I=p;if(f&&"number"==typeof f.length&&Array.prototype.toString.call(f)&&f.forEach(function(e){y[e+""]=e+""}),"string"!=typeof e)return"";"string"==typeof a?p=a:"object"==typeof a&&(b&&(I+=w.join("")),A&&(I+=S.join("")),j&&(I+=v.join(""))),Object.keys(y).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,y[a])});for(c in y)I+=c;f&&(e=e.replace(/(\w)(\S*)/g,function(e,a,n){var o=a.toUpperCase()+(null!==n?n:"");return Object.keys(y).indexOf(o.toLowerCase())<0?o:o.toLowerCase()})),I=o(I),e=e.replace(/(^\s+|\s+$)/g,""),m=!1,h=!1;var R=function(e,a){for(var n in a)if(a[n]==e)return!0};for(s=0,g=e.length;g>s;s++)c=e[s],R(c,y)?m=!1:O[c]?(c=m&&O[c].match(/[A-Za-z0-9]/)?" "+O[c]:O[c],m=!1):c in t?(g>s+1&&i.indexOf(e[s+1])>=0?(z+=c,c=""):h===!0?(c=u[z]+t[c],z=""):c=m&&t[c].match(/[A-Za-z0-9]/)?" "+t[c]:t[c],m=!1,h=!1):c in u?(z+=c,c="",s==g-1&&(c=u[z]),h=!0):!E[c]||b&&-1!==w.join("").indexOf(c)||A&&-1!==S.join("").indexOf(c)||j&&-1!==v.join("").indexOf(c)?(h===!0?(c=u[z]+c,z="",h=!1):m&&(/[A-Za-z0-9]/.test(c)||U.substr(-1).match(/A-Za-z0-9]/))&&(c=" "+c),m=!1):(c=m||U.substr(-1).match(/[A-Za-z0-9]/)?p+E[c]:E[c],c+=void 0!==e[s+1]&&e[s+1].match(/[A-Za-z0-9]/)?p:"",m=!0),U+=c.replace(new RegExp("[^\\w\\s"+I+"_-]","g"),p);return U=U.replace(/\s+/g,p).replace(new RegExp("\\"+p+"+","g"),p).replace(new RegExp("(^\\"+p+"+|\\"+p+"+$)","g"),""),k&&U.length>k&&(n=U.charAt(k)===p,U=U.slice(0,k),n||(U=U.slice(0,U.lastIndexOf(p)))),d||f||f.length||(U=U.toLowerCase()),U},n=function(e){return function(n){return a(n,e)}},o=function(e){return e.replace(/[-\\^$*+?.()|[\]{}\/]/g,"\\$&")},t={"À":"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","က":"k","ခ":"kh","ဂ":"g","ဃ":"ga","င":"ng","စ":"s","ဆ":"sa","ဇ":"z","စျ":"za","ည":"ny","ဋ":"t","ဌ":"ta","ဍ":"d","ဎ":"da","ဏ":"na","တ":"t","ထ":"ta","ဒ":"d","ဓ":"da","န":"n","ပ":"p","ဖ":"pa","ဗ":"b","ဘ":"ba","မ":"m","ယ":"y","ရ":"ya","လ":"l","ဝ":"w","သ":"th","ဟ":"h","ဠ":"la","အ":"a","ြ":"y","ျ":"ya","ွ":"w","ြွ":"yw","ျွ":"ywa","ှ":"h","ဧ":"e","၏":"-e","ဣ":"i","ဤ":"-i","ဉ":"u","ဦ":"-u","ဩ":"aw","သြော":"aw","ဪ":"aw","၀":"0","၁":"1","၂":"2","၃":"3","၄":"4","၅":"5","၆":"6","၇":"7","၈":"8","၉":"9","္":"","့":"","း":""},i=["်"],u={"ာ":"a","ါ":"a","ေ":"e","ဲ":"e","ိ":"i","ီ":"i","ို":"o","ု":"u","ူ":"u","ေါင်":"aung","ော":"aw","ော်":"aw","ေါ":"aw","ေါ်":"aw","်":"်","က်":"et","ိုက်":"aik","ောက်":"auk","င်":"in","ိုင်":"aing","ောင်":"aung","စ်":"it","ည်":"i","တ်":"at","ိတ်":"eik","ုတ်":"ok","ွတ်":"ut","ေတ်":"it","ဒ်":"d","ိုဒ်":"ok","ုဒ်":"ait","န်":"an","ာန်":"an","ိန်":"ein","ုန်":"on","ွန်":"un","ပ်":"at","ိပ်":"eik","ုပ်":"ok","ွပ်":"ut","န်ုပ်":"nub","မ်":"an","ိမ်":"ein","ုမ်":"on","ွမ်":"un","ယ်":"e","ိုလ်":"ol","ဉ်":"in","ံ":"an","ိံ":"ein","ုံ":"on"},r={en:{},hu:{"ä":"a","Ä":"A","ö":"o","Ö":"O","ü":"u","Ü":"U","ű":"u","Ű":"U"},sk:{"ä":"a","Ä":"A"},tr:{"Ü":"U","Ö":"O","ü":"u","ö":"o"}},l={ar:{"∆":"delta","∞":"la-nihaya","♥":"hob","&":"wa","|":"aw","<":"aqal-men",">":"akbar-men","∑":"majmou","¤":"omla"},cz:{"∆":"delta","∞":"nekonecno","♥":"laska","&":"a","|":"nebo","<":"mene jako",">":"vice jako","∑":"soucet","¤":"mena"},de:{"∆":"delta","∞":"unendlich","♥":"Liebe","&":"und","|":"oder","<":"kleiner als",">":"groesser als","∑":"Summe von","¤":"Waehrung"},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"},hu:{"∆":"delta","∞":"vegtelen","♥":"szerelem","&":"es","|":"vagy","<":"kisebb mint",">":"nagyobb mint","∑":"szumma","¤":"penznem"},my:{"∆":"kwahkhyaet","∞":"asaonasme","♥":"akhyait","&":"nhin","|":"tho","<":"ngethaw",">":"kyithaw","∑":"paungld","¤":"ngwekye"},nl:{"∆":"delta","∞":"oneindig","♥":"liefde","&":"en","|":"of","<":"kleiner dan",">":"groter dan","∑":"som","¤":"valuta"},it:{"∆":"delta","∞":"infinito","♥":"amore","&":"e","|":"o","<":"minore di",">":"maggiore di","∑":"somma","¤":"moneta"},pt:{"∆":"delta","∞":"infinito","♥":"amor","&":"e","|":"ou","<":"menor que",">":"maior que","∑":"soma","¤":"moeda"},ru:{"∆":"delta","∞":"beskonechno","♥":"lubov","&":"i","|":"ili","<":"menshe",">":"bolshe","∑":"summa","¤":"valjuta"},sk:{"∆":"delta","∞":"nekonecno","♥":"laska","&":"a","|":"alebo","<":"menej ako",">":"viac ako","∑":"sucet","¤":"mena"},tr:{"∆":"delta","∞":"sonsuzluk","♥":"ask","&":"ve","|":"veya","<":"kucuktur",">":"buyuktur","∑":"toplam","¤":"para birimi"},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=n;else if("undefined"!=typeof define&&define.amd)define([],function(){return a});else try{if(e.getSlug||e.createSlug)throw"speakingurl: globals exists /(getSlug|createSlug)/";e.getSlug=a,e.createSlug=n}catch(s){}}(this);
*/!function(e){"use strict";var a=function(e,a){var t,c,m,g,f,y,h,d="object"==typeof a&&a.maintainCase||!1,p="object"==typeof a&&"object"==typeof a.custom&&a.custom?a.custom:{},k="object"==typeof a&&a.separator||"-",b="object"==typeof a&&+a.truncate>1&&a.truncate||!1,A="object"==typeof a&&a.uric||!1,j="object"==typeof a&&a.uricNoSlash||!1,E="object"==typeof a&&a.mark||!1,O="object"==typeof a&&a.lang&&s[a.lang]?s[a.lang]:"object"!=typeof a||a.lang!==!1&&a.lang!==!0?s.en:{},w="object"==typeof a&&a.lang&&l[a.lang]?l[a.lang]:"object"!=typeof a||a.lang!==!1&&a.lang!==!0?l.en:{},S=[";","?",":","@","&","=","+","$",",","/"],v=[";","?",":","@","&","=","+","$",","],U=[".","!","~","*","'","(",")"],z="",I="",R=k;if("object"==typeof a&&a.titleCase&&"number"==typeof a.titleCase.length&&Array.prototype.toString.call(a.titleCase)?(a.titleCase.forEach(function(e){p[e+""]=e+""}),t=!0):t="object"==typeof a&&!!a.titleCase,"object"==typeof a&&a.custom&&"number"==typeof a.custom.length&&Array.prototype.toString.call(a.custom)&&a.custom.forEach(function(e){p[e+""]=e+""}),"string"!=typeof e)return"";"string"==typeof a?k=a:"object"==typeof a&&(A&&(R+=S.join("")),j&&(R+=v.join("")),E&&(R+=U.join(""))),Object.keys(p).forEach(function(a){var t;t=a.length>1?new RegExp("\\b"+n(a)+"\\b","gi"):new RegExp(n(a),"gi"),e=e.replace(t,p[a])});for(g in p)R+=g;for(t&&(e=e.replace(/(\w)(\S*)/g,function(e,a,t){var n=a.toUpperCase()+(null!==t?t:"");return Object.keys(p).indexOf(n.toLowerCase())<0?n:n.toLowerCase()})),R=n(R),e=e.replace(/(^\s+|\s+$)/g,""),y=!1,h=!1,m=0,f=e.length;f>m;m++)g=e[m],o(g,p)?y=!1:w[g]?(g=y&&w[g].match(/[A-Za-z0-9]/)?" "+w[g]:w[g],y=!1):g in i?(f>m+1&&u.indexOf(e[m+1])>=0?(I+=g,g=""):h===!0?(g=r[I]+i[g],I=""):g=y&&i[g].match(/[A-Za-z0-9]/)?" "+i[g]:i[g],y=!1,h=!1):g in r?(I+=g,g="",m===f-1&&(g=r[I]),h=!0):!O[g]||A&&-1!==S.join("").indexOf(g)||j&&-1!==v.join("").indexOf(g)||E&&-1!==U.join("").indexOf(g)?(h===!0?(g=r[I]+g,I="",h=!1):y&&(/[A-Za-z0-9]/.test(g)||z.substr(-1).match(/A-Za-z0-9]/))&&(g=" "+g),y=!1):(g=y||z.substr(-1).match(/[A-Za-z0-9]/)?k+O[g]:O[g],g+=void 0!==e[m+1]&&e[m+1].match(/[A-Za-z0-9]/)?k:"",y=!0),z+=g.replace(new RegExp("[^\\w\\s"+R+"_-]","g"),k);return z=z.replace(/\s+/g,k).replace(new RegExp("\\"+k+"+","g"),k).replace(new RegExp("(^\\"+k+"+|\\"+k+"+$)","g"),""),b&&z.length>b&&(c=z.charAt(b)===k,z=z.slice(0,b),c||(z=z.slice(0,z.lastIndexOf(k)))),d||t||(z=z.toLowerCase()),z},t=function(e){return function(t){return a(t,e)}},n=function(e){return e.replace(/[-\\^$*+?.()|[\]{}\/]/g,"\\$&")},o=function(e,a){for(var t in a)if(a[t]===e)return!0},i={"À":"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","က":"k","ခ":"kh","ဂ":"g","ဃ":"ga","င":"ng","စ":"s","ဆ":"sa","ဇ":"z","စျ":"za","ည":"ny","ဋ":"t","ဌ":"ta","ဍ":"d","ဎ":"da","ဏ":"na","တ":"t","ထ":"ta","ဒ":"d","ဓ":"da","န":"n","ပ":"p","ဖ":"pa","ဗ":"b","ဘ":"ba","မ":"m","ယ":"y","ရ":"ya","လ":"l","ဝ":"w","သ":"th","ဟ":"h","ဠ":"la","အ":"a","ြ":"y","ျ":"ya","ွ":"w","ြွ":"yw","ျွ":"ywa","ှ":"h","ဧ":"e","၏":"-e","ဣ":"i","ဤ":"-i","ဉ":"u","ဦ":"-u","ဩ":"aw","သြော":"aw","ဪ":"aw","၀":"0","၁":"1","၂":"2","၃":"3","၄":"4","၅":"5","၆":"6","၇":"7","၈":"8","၉":"9","္":"","့":"","း":""},u=["်"],r={"ာ":"a","ါ":"a","ေ":"e","ဲ":"e","ိ":"i","ီ":"i","ို":"o","ု":"u","ူ":"u","ေါင်":"aung","ော":"aw","ော်":"aw","ေါ":"aw","ေါ်":"aw","်":"်","က်":"et","ိုက်":"aik","ောက်":"auk","င်":"in","ိုင်":"aing","ောင်":"aung","စ်":"it","ည်":"i","တ်":"at","ိတ်":"eik","ုတ်":"ok","ွတ်":"ut","ေတ်":"it","ဒ်":"d","ိုဒ်":"ok","ုဒ်":"ait","န်":"an","ာန်":"an","ိန်":"ein","ုန်":"on","ွန်":"un","ပ်":"at","ိပ်":"eik","ုပ်":"ok","ွပ်":"ut","န်ုပ်":"nub","မ်":"an","ိမ်":"ein","ုမ်":"on","ွမ်":"un","ယ်":"e","ိုလ်":"ol","ဉ်":"in","ံ":"an","ိံ":"ein","ုံ":"on"},l={en:{},hu:{"ä":"a","Ä":"A","ö":"o","Ö":"O","ü":"u","Ü":"U","ű":"u","Ű":"U"},sk:{"ä":"a","Ä":"A"},tr:{"Ü":"U","Ö":"O","ü":"u","ö":"o"}},s={ar:{"∆":"delta","∞":"la-nihaya","♥":"hob","&":"wa","|":"aw","<":"aqal-men",">":"akbar-men","∑":"majmou","¤":"omla"},cz:{"∆":"delta","∞":"nekonecno","♥":"laska","&":"a","|":"nebo","<":"mene jako",">":"vice jako","∑":"soucet","¤":"mena"},de:{"∆":"delta","∞":"unendlich","♥":"Liebe","&":"und","|":"oder","<":"kleiner als",">":"groesser als","∑":"Summe von","¤":"Waehrung"},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"},hu:{"∆":"delta","∞":"vegtelen","♥":"szerelem","&":"es","|":"vagy","<":"kisebb mint",">":"nagyobb mint","∑":"szumma","¤":"penznem"},my:{"∆":"kwahkhyaet","∞":"asaonasme","♥":"akhyait","&":"nhin","|":"tho","<":"ngethaw",">":"kyithaw","∑":"paungld","¤":"ngwekye"},nl:{"∆":"delta","∞":"oneindig","♥":"liefde","&":"en","|":"of","<":"kleiner dan",">":"groter dan","∑":"som","¤":"valuta"},it:{"∆":"delta","∞":"infinito","♥":"amore","&":"e","|":"o","<":"minore di",">":"maggiore di","∑":"somma","¤":"moneta"},pt:{"∆":"delta","∞":"infinito","♥":"amor","&":"e","|":"ou","<":"menor que",">":"maior que","∑":"soma","¤":"moeda"},ru:{"∆":"delta","∞":"beskonechno","♥":"lubov","&":"i","|":"ili","<":"menshe",">":"bolshe","∑":"summa","¤":"valjuta"},sk:{"∆":"delta","∞":"nekonecno","♥":"laska","&":"a","|":"alebo","<":"menej ako",">":"viac ako","∑":"sucet","¤":"mena"},tr:{"∆":"delta","∞":"sonsuzluk","♥":"ask","&":"ve","|":"veya","<":"kucuktur",">":"buyuktur","∑":"toplam","¤":"para birimi"},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=t;else if("undefined"!=typeof define&&define.amd)define([],function(){return a});else try{if(e.getSlug||e.createSlug)throw"speakingurl: globals exists /(getSlug|createSlug)/";e.getSlug=a,e.createSlug=t}catch(c){}}(this);

@@ -44,2 +44,32 @@ /* global describe,it */

getSlug('[Knöpfe]', {
custom: ['[', ']']
})
.should.eql('[knoepfe]');
getSlug('[Knöpfe]', {
maintainCase: true,
custom: ['[', ']']
})
.should.eql('[Knoepfe]');
getSlug('[Knöpfe haben Löcher]', {
titleCase: true,
custom: ['[', ']']
})
.should.eql('[Knoepfe-Haben-Loecher]');
getSlug('[knöpfe haben runde löcher]', {
titleCase: ['haben', 'runde'],
custom: ['[', ']']
})
.should.eql('[Knoepfe-haben-runde-Loecher]');
getSlug('[knöpfe haben runde löcher]', {
titleCase: ['haben', 'runde'],
maintainCase: true,
custom: ['[', ']']
})
.should.eql('[Knoepfe-haben-runde-Loecher]');
done();

@@ -46,0 +76,0 @@ });

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc