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 0.2.9 to 0.2.10

test/test-create.js

2

bower.json
{
"name": "speakingurl",
"version": "0.2.9",
"version": "0.2.10",
"description": "Generate of so called 'static' or 'nice-looking' or 'slug' or 'SpeakingURL' from a string.",

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

@@ -77,2 +77,10 @@ 'use strict';

console.log(slug); // Output: foo-and-bar-or-(baz)-boo-doo
console.log("\n");
slug = getSlug('NEXUS4 only $299');
console.log(slug); // Output: nexus-4-only-usd-299
console.log("\n");
slug = getSlug('NEXUS4 only €299', {maintainCase: true});
console.log(slug); // Output: NEXUS-4-only-EUR-299
console.log("\n");

@@ -431,4 +431,2 @@ (function () {

// TODO sfasdf
if (typeof string !== 'string') {

@@ -467,13 +465,13 @@ return '';

if (customChars[ch]) {
ch = lastCharWasSymbol && customChars[ch].match(/[A-Za-z]/) ? ' ' + customChars[ch] : customChars[ch];
ch = lastCharWasSymbol && customChars[ch].match(/[\w]/) ? ' ' + customChars[ch] : customChars[ch];
lastCharWasSymbol = false;
} else if (charMap[ch]) {
ch = lastCharWasSymbol && charMap[ch].match(/[A-Za-z]/) ? ' ' + charMap[ch] : charMap[ch];
ch = lastCharWasSymbol && charMap[ch].match(/[\w]/) ? ' ' + charMap[ch] : charMap[ch];
lastCharWasSymbol = false;
} else if (symbol[ch] && !(uricFlag && uricChars.join('')
.indexOf(ch) !== -1) && !(uricNoSlashFlag && uricNoSlashChars.join('')
.indexOf(ch) !== -1) && !(markFlag && markChars.join('')
.indexOf(ch) !== -1)) {
} else if (symbol[ch] &&
!(uricFlag && uricChars.join('').indexOf(ch) !== -1) &&
!(uricNoSlashFlag && uricNoSlashChars.join('').indexOf(ch) !== -1) &&
!(markFlag && markChars.join('').indexOf(ch) !== -1)) {
if (lastCharWasSymbol || (result.length && result[result.length - 1].match(/[A-Za-z]/))) {
if (lastCharWasSymbol || result.substr(-1).match(/[\w]/)) {
ch = ' ' + symbol[ch];

@@ -483,11 +481,13 @@ } else {

}
lastCharWasSymbol = true;
} else {
ch = lastCharWasSymbol && ch.match(/[A-Za-z]/) || (result.length && result[result.length - 1].match(/[^\d]/) && ch.match(/[\d]/)) ? ' ' + ch : ch;
lastCharWasSymbol = false;
if (lastCharWasSymbol && ch.match(/[\w]/)) {
ch = ' ' + ch;
lastCharWasSymbol = false;
}
}
// add allowed chars
result += ch.replace(new RegExp('[^A-Za-z0-9-_\\w\\s' + allowedChars + '-]', 'g'), '');
result += ch.replace(new RegExp('[^\\w\\s' + allowedChars + '_-]', 'g'), '');
}

@@ -516,7 +516,16 @@

var createSlug = function createSlug(opts) {
return function (string) {
return getSlug(string, opts);
};
};
if (typeof module !== 'undefined') {
module.exports = getSlug;
module.exports.createSlug = createSlug;
} else {
window.getSlug = getSlug;
// don't overwrite if exists
window.getSlug = window.getSlug || getSlug;
window.createSlug = window.createSlug || createSlug;
}
})();
{
"name": "speakingurl",
"version": "0.2.9",
"version": "0.2.10",
"description": "Generate of so called 'static' or 'nice-looking' or 'SpeakingURL' or 'slug' from a string.",
"homepage": "https://github.com/pid/speakingurl",
"keywords": [
"slug",
"seo",
"url",
"speakingurl",
"nice url",
"static url"
"slug",
"seo",
"url",
"speakingurl",
"nice url",
"static url"
],

@@ -35,23 +35,7 @@ "author": {

"browsers": {
"ie": [
6,
7,
8,
9,
10
],
"firefox": [
19
],
"chrome": [
25
],
"safari": [
5.1,
6
],
"opera": [
10,
12
]
"ie": [6, 7, 8, 9, 10 ],
"firefox": [19 ],
"chrome": [25 ],
"safari": [5.1, 6 ],
"opera": [10, 12 ]
}

@@ -69,4 +53,3 @@ },

},
"licenses": [
{
"licenses": [{
"type": "MIT",

@@ -73,0 +56,0 @@ "url": "https://raw.github.com/pid/speakingurl/master/LICENCE"

@@ -1,2 +0,3 @@

# Speaking URL [![NPM version](https://badge.fury.io/js/speakingurl.png)](http://badge.fury.io/js/speakingurl)
# 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)
Generate of so called "static" or "nice-looking" or "SpeakingURL" or "slug" from a string.

@@ -6,3 +7,3 @@

For use in browser and server.
For use in browser and server - no dependencies!

@@ -50,62 +51,99 @@ ## Installation

## Examples
```javascript
var getSlug = require('speakingurl'),
slug;
var getSlug = require('speakingurl');
var slug;
slug = getSlug("Schöner Titel läßt grüßen!? Bel été !");
console.log(slug);
// Output: schoener-titel-laesst-gruessen-bel-ete
console.log(slug); // Output: schoener-titel-laesst-gruessen-bel-ete
slug = getSlug("Schöner Titel läßt grüßen!? Bel été !", "*");
console.log(slug);
// Output: schoener*titel*laesst*gruessen*bel*ete
console.log(slug); // Output: schoener*titel*laesst*gruessen*bel*ete
slug = getSlug("Schöner Titel läßt grüßen!? Bel été !", {separator: "_"});
console.log(slug);
// Output: schoener_titel_laesst_gruessen_bel_ete
console.log(slug); // Output: schoener_titel_laesst_gruessen_bel_ete
slug = getSlug("Schöner Titel läßt grüßen!? Bel été !", {uric: true});
console.log(slug);
// Output: schoener-titel-laesst-gruessen?-bel-ete
console.log(slug); // Output: schoener-titel-laesst-gruessen?-bel-ete
slug = getSlug("Schöner Titel läßt grüßen!? Bel été !", {uricNoSlash: true});
console.log(slug);
// Output: schoener-titel-laesst-gruessen?-bel-ete
console.log(slug); // Output: schoener-titel-laesst-gruessen?-bel-ete
slug = getSlug("Schöner Titel läßt grüßen!? Bel été !", {mark: true});
console.log(slug);
// Output: schoener-titel-laesst-gruessen!-bel-ete-!
console.log(slug); // Output: schoener-titel-laesst-gruessen!-bel-ete-!
slug = getSlug("Schöner Titel läßt grüßen!? Bel été !", {truncate: 20});
console.log(slug);
// Output: schoener-titel
console.log(slug); // Output: schoener-titel
slug = getSlug("Schöner Titel läßt grüßen!? Bel été !", {maintainCase: true});
console.log(slug);
// Output: Schoener-Titel-laesst-gruessen-Bel-ete
console.log(slug); // Output: Schoener-Titel-laesst-gruessen-Bel-ete
slug = getSlug("Äpfel & Birnen!", {lang: 'de'});
console.log(slug);
// Output: aepfel-und-birnen
console.log(slug); // Output: aepfel-und-birnen
slug = getSlug("Apple & Pear!", {lang: 'en'}); // lang: "en" is default, just to clarify
console.log(slug);
// Output: apple-and-pear
console.log(slug); // Output: apple-and-pear
slug = getSlug('Foo & Bar * Baz', {custom: {'&': ' doo '}, uric:true } );
console.log(slug);
// Output: foo-doo-bar-baz
console.log(slug); // Output: foo-doo-bar-baz
slug = getSlug('Foo ♥ Bar');
console.log(slug);
// Output: foo-love-bar
console.log(slug); // Output: foo-love-bar
slug = getSlug('Foo & Bar | (Baz) * Doo', {custom:{'*': "Boo"},mark:true});
console.log(slug);
// Output: foo-and-bar-or-(baz)-boo-doo
console.log(slug); // Output: foo-and-bar-or-(baz)-boo-doo
slug = getSlug('NEXUS4 only $299');
console.log(slug); // Output: nexus-4-only-usd-299
slug = getSlug('NEXUS4 only €299', {maintainCase: true});
console.log(slug); // Output: NEXUS-4-only-EUR-299
```
In browser:
```html
<script src="components/speakingurl/speakingurl.min.js"></script>
<script>
var slug = getSlug('NEXUS4 only €299', {maintainCase: true});
console.log(slug); // Output: NEXUS-4-only-EUR-299
</script>
```
### createSlug([options])
```options```: {object|string} config object or separator string (see above)
Create your own specially configured function.
```javascript
var slug;
var options = {
maintainCase: true,
separator: '_',
truncate: 14
};
var mySlug = require('speakingurl').createSlug(options);
slug = mySlug("Schöner Titel läßt grüßen!? Bel été !");
console.log(slug); // Output: Schoener_Titel_laesst_gruessen_Bel_ete
```
In browser:
```html
<script src="components/speakingurl/speakingurl.min.js"></script>
<script>
var options = {
maintainCase: true,
separator: '_',
truncate: 14
};
var mySlug = createSlug(options);
var slug = mySlug("Schöner Titel läßt grüßen!? Bel été !");
console.log(slug); // Output: Schoener_Titel_laesst_gruessen_Bel_ete
</script>
```
## Tests

@@ -118,2 +156,9 @@ [![Build Status](https://travis-ci.org/pid/speakingurl.png)](https://travis-ci.org/pid/speakingurl)

## History
- 0.2.10 added createSlug function
## References
- http://tools.ietf.org/html/rfc3986
- http://en.wikipedia.org/wiki/Transliteration
## Credits

@@ -124,6 +169,2 @@ - [@dypsilon](https://github.com/dypsilon/js-replace-diacritics)

## Informations
- http://tools.ietf.org/html/rfc3986
- http://en.wikipedia.org/wiki/Transliteration
## License

@@ -130,0 +171,0 @@ [BSD](https://raw.github.com/pid/speakingurl/master/LICENCE)

@@ -1,2 +0,2 @@

/* speakingurl v0.2.9 (c) 2013 Sascha Droste https://github.com/pid/speakingurl */
!function(){"use strict";var a={"À":"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","β":"b","γ":"g","δ":"d","ε":"e","ζ":"z","η":"h","θ":"8","ι":"i","κ":"k","λ":"l","μ":"m","ν":"n","ξ":"3","ο":"o","π":"p","ρ":"r","σ":"s","τ":"t","υ":"y","φ":"f","χ":"x","ψ":"ps","ω":"w","ά":"a","έ":"e","ί":"i","ό":"o","ύ":"y","ή":"h","ώ":"w","ς":"s","ϊ":"i","ΰ":"y","ϋ":"y","ΐ":"i","Α":"A","Β":"B","Γ":"G","Δ":"D","Ε":"E","Ζ":"Z","Η":"H","Θ":"8","Ι":"I","Κ":"K","Λ":"L","Μ":"M","Ν":"N","Ξ":"3","Ο":"O","Π":"P","Ρ":"R","Σ":"S","Τ":"T","Υ":"Y","Φ":"F","Χ":"X","Ψ":"PS","Ω":"W","Ά":"A","Έ":"E","Ί":"I","Ό":"O","Ύ":"Y","Ή":"H","Ώ":"W","Ϊ":"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","ъ":"u","ы":"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","Ъ":"U","Ы":"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","ą":"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","“":'"',"”":'"',"‘":"'","’":"'","∂":"d","ƒ":"f","™":"(TM)","©":"(C)","œ":"oe","Œ":"OE","®":"(R)","†":"+","℠":"(SM)","…":"...","˚":"o","º":"o","ª":"a","•":"*",$:"USD","€":"EUR","₢":"BRN","₣":"FRF","£":"GBP","₤":"ITL","₦":"NGN","₧":"ESP","₨":"INR","₩":"KRW","₪":"ILS","₫":"VND","₭":"LAK","₮":"MNT","₯":"GRD","₱":"ARS","₲":"PYG","₳":"ARA","₴":"UAH","₵":"GHS","¢":"cent","¥":"CNY","元":"CNY","円":"YEN","﷼":"IRR","₠":"EWE","฿":"THB"},b={en:{"∆":"delta","∞":"infinity","♥":"love","&":"and","|":"or","<":"less than",">":"greater than","∑":"sum","¤":"currency"},de:{"∆":"delta","∞":"unendlich","♥":"Liebe","&":"und","|":"oder","<":"kleiner als",">":"groesser als","∑":"Summe von","¤":"Waehrung"},fr:{"∆":"delta","∞":"infiniment","♥":"Amour","&":"et","|":"ou","<":"moins que",">":"superieure a","∑":"somme des","¤":"monnaie"},es:{"∆":"delta","∞":"infinito","♥":"amor","&":"y","|":"u","<":"menos que",">":"mas que","∑":"suma de los","¤":"moneda"},ru:{"∆":"delta","∞":"beskonechno","♥":"lubov","&":"i","|":"ili","<":"menshe",">":"bolshe","∑":"summa","¤":"valjuta"}},c=function(c,d){var e,f,g,h,i,j="object"==typeof d&&d.maintainCase||!1,k="object"==typeof d&&d.separator||"-",l="object"==typeof d&&d.truncate,m="object"==typeof d&&d.lang||"en",n="object"==typeof d&&d.uric||!1,o="object"==typeof d&&d.uricNoSlash||!1,p="object"==typeof d&&d.mark||!1,q=b[m]||b.en,r="object"==typeof d&&d.custom||{},s=[";","?",":","@","&","=","+","$",",","/"],t=[";","?",":","@","&","=","+","$",","],u=[".","!","~","*","'","(",")"],v="",w=[];if("string"!=typeof c)return"";for("string"==typeof d?k=d:"object"==typeof d&&(n&&(w=w.concat(s)),o&&(w=w.concat(t)),p&&(w=w.concat(u))),w=(w.join("")+k).replace(/[-\\^$*+?.()|[\]{}\/]/g,"\\$&"),c=c.replace(/(^\s+|\s+$)/g,""),i=!1,f=0,h=c.length;h>f;f++)g=c[f],r[g]?(g=i&&r[g].match(/[A-Za-z]/)?" "+r[g]:r[g],i=!1):a[g]?(g=i&&a[g].match(/[A-Za-z]/)?" "+a[g]:a[g],i=!1):!q[g]||n&&-1!==s.join("").indexOf(g)||o&&-1!==t.join("").indexOf(g)||p&&-1!==u.join("").indexOf(g)?(g=i&&g.match(/[A-Za-z]/)||v.length&&v[v.length-1].match(/[^\d]/)&&g.match(/[\d]/)?" "+g:g,i=!1):(g=i||v.length&&v[v.length-1].match(/[A-Za-z]/)?" "+q[g]:q[g],i=!0),v+=g.replace(new RegExp("[^A-Za-z0-9-_\\w\\s"+w+"-]","g"),"");return v=v.replace(/\s+/g,k).replace(new RegExp("\\"+k+"+","g"),k).replace(new RegExp("(^\\"+k+"+|\\"+k+"+$)","g"),""),l&&v.length>l&&(e=v.charAt(l)===k,v=v.slice(0,l),e||(v=v.slice(0,v.lastIndexOf(k)))),j||(v=v.toLowerCase()),v};"undefined"!=typeof module?module.exports=c:window.getSlug=c}();
/* speakingurl v0.2.10 (c) 2013 Sascha Droste https://github.com/pid/speakingurl */
!function(){"use strict";var a={"À":"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","β":"b","γ":"g","δ":"d","ε":"e","ζ":"z","η":"h","θ":"8","ι":"i","κ":"k","λ":"l","μ":"m","ν":"n","ξ":"3","ο":"o","π":"p","ρ":"r","σ":"s","τ":"t","υ":"y","φ":"f","χ":"x","ψ":"ps","ω":"w","ά":"a","έ":"e","ί":"i","ό":"o","ύ":"y","ή":"h","ώ":"w","ς":"s","ϊ":"i","ΰ":"y","ϋ":"y","ΐ":"i","Α":"A","Β":"B","Γ":"G","Δ":"D","Ε":"E","Ζ":"Z","Η":"H","Θ":"8","Ι":"I","Κ":"K","Λ":"L","Μ":"M","Ν":"N","Ξ":"3","Ο":"O","Π":"P","Ρ":"R","Σ":"S","Τ":"T","Υ":"Y","Φ":"F","Χ":"X","Ψ":"PS","Ω":"W","Ά":"A","Έ":"E","Ί":"I","Ό":"O","Ύ":"Y","Ή":"H","Ώ":"W","Ϊ":"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","ъ":"u","ы":"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","Ъ":"U","Ы":"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","ą":"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","“":'"',"”":'"',"‘":"'","’":"'","∂":"d","ƒ":"f","™":"(TM)","©":"(C)","œ":"oe","Œ":"OE","®":"(R)","†":"+","℠":"(SM)","…":"...","˚":"o","º":"o","ª":"a","•":"*",$:"USD","€":"EUR","₢":"BRN","₣":"FRF","£":"GBP","₤":"ITL","₦":"NGN","₧":"ESP","₨":"INR","₩":"KRW","₪":"ILS","₫":"VND","₭":"LAK","₮":"MNT","₯":"GRD","₱":"ARS","₲":"PYG","₳":"ARA","₴":"UAH","₵":"GHS","¢":"cent","¥":"CNY","元":"CNY","円":"YEN","﷼":"IRR","₠":"EWE","฿":"THB"},b={en:{"∆":"delta","∞":"infinity","♥":"love","&":"and","|":"or","<":"less than",">":"greater than","∑":"sum","¤":"currency"},de:{"∆":"delta","∞":"unendlich","♥":"Liebe","&":"und","|":"oder","<":"kleiner als",">":"groesser als","∑":"Summe von","¤":"Waehrung"},fr:{"∆":"delta","∞":"infiniment","♥":"Amour","&":"et","|":"ou","<":"moins que",">":"superieure a","∑":"somme des","¤":"monnaie"},es:{"∆":"delta","∞":"infinito","♥":"amor","&":"y","|":"u","<":"menos que",">":"mas que","∑":"suma de los","¤":"moneda"},ru:{"∆":"delta","∞":"beskonechno","♥":"lubov","&":"i","|":"ili","<":"menshe",">":"bolshe","∑":"summa","¤":"valjuta"}},c=function(c,d){var e,f,g,h,i,j="object"==typeof d&&d.maintainCase||!1,k="object"==typeof d&&d.separator||"-",l="object"==typeof d&&d.truncate,m="object"==typeof d&&d.lang||"en",n="object"==typeof d&&d.uric||!1,o="object"==typeof d&&d.uricNoSlash||!1,p="object"==typeof d&&d.mark||!1,q=b[m]||b.en,r="object"==typeof d&&d.custom||{},s=[";","?",":","@","&","=","+","$",",","/"],t=[";","?",":","@","&","=","+","$",","],u=[".","!","~","*","'","(",")"],v="",w=[];if("string"!=typeof c)return"";for("string"==typeof d?k=d:"object"==typeof d&&(n&&(w=w.concat(s)),o&&(w=w.concat(t)),p&&(w=w.concat(u))),w=(w.join("")+k).replace(/[-\\^$*+?.()|[\]{}\/]/g,"\\$&"),c=c.replace(/(^\s+|\s+$)/g,""),i=!1,f=0,h=c.length;h>f;f++)g=c[f],r[g]?(g=i&&r[g].match(/[\w]/)?" "+r[g]:r[g],i=!1):a[g]?(g=i&&a[g].match(/[\w]/)?" "+a[g]:a[g],i=!1):!q[g]||n&&-1!==s.join("").indexOf(g)||o&&-1!==t.join("").indexOf(g)||p&&-1!==u.join("").indexOf(g)?i&&g.match(/[\w]/)&&(g=" "+g,i=!1):(g=i||v.substr(-1).match(/[\w]/)?" "+q[g]:q[g],i=!0),v+=g.replace(new RegExp("[^\\w\\s"+w+"_-]","g"),"");return v=v.replace(/\s+/g,k).replace(new RegExp("\\"+k+"+","g"),k).replace(new RegExp("(^\\"+k+"+|\\"+k+"+$)","g"),""),l&&v.length>l&&(e=v.charAt(l)===k,v=v.slice(0,l),e||(v=v.slice(0,v.lastIndexOf(k)))),j||(v=v.toLowerCase()),v},d=function(a){return function(b){return c(b,a)}};"undefined"!=typeof module?(module.exports=c,module.exports.createSlug=d):(window.getSlug=window.getSlug||c,window.createSlug=window.createSlug||d)}();

@@ -22,2 +22,8 @@ /* global describe,it */

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');
done();

@@ -41,2 +47,8 @@

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');
done();

@@ -60,2 +72,8 @@

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');
done();

@@ -78,2 +96,8 @@ });

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');
done();

@@ -97,2 +121,8 @@

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');
done();

@@ -107,2 +137,4 @@ });

getSlug(' C\'est un beau titre qui ne laisse rien à désirer !', '*').should.eql('cest*un*beau*titre*qui*ne*laisse*rien*a*desirer');
done();

@@ -109,0 +141,0 @@

@@ -97,3 +97,5 @@ /* global describe,it */

maintainCase: true,
onlyBase64: true
uric: false,
uricNoSlash: false,
mark: false
}).should.eql('Foo-Bar-Baz');

@@ -103,3 +105,5 @@

maintainCase: true,
onlyBase64: true
uric: false,
uricNoSlash: false,
mark: false
}).should.eql('Foo-Bar-Baz');

@@ -109,3 +113,5 @@

maintainCase: true,
onlyBase64: true
uric: false,
uricNoSlash: false,
mark: false
}).should.eql('Foo-Bar-Baz');

@@ -144,19 +150,23 @@

getSlug('Foo, Bar Baz', {
rfc3986: true,
onlyBase64: true
uric: false,
uricNoSlash: false,
mark: false
}).should.eql('foo-bar-baz');
getSlug('Foo- Bar Baz', {
rfc3986: true,
onlyBase64: true
uric: false,
uricNoSlash: false,
mark: false
}).should.eql('foo-bar-baz');
getSlug('Foo] Bar Baz', {
rfc3986: true,
onlyBase64: true
uric: false,
uricNoSlash: false,
mark: false
}).should.eql('foo-bar-baz');
getSlug('Foo* Bar Baz', {
rfc3986: true,
onlyBase64: true
uric: false,
uricNoSlash: false,
mark: false
}).should.eql('foo-bar-baz');

@@ -163,0 +173,0 @@

@@ -162,2 +162,11 @@ /* global describe,it */

}).should.eql('foo-(lubov)-;-baz=bar');
getSlug(' Sch(* )ner (♥)Ti♥tel ♥läßt grüßen!? Bel♥♥ été !', {
lang: 'en',
uric: true,
uricNoSlash: true,
mark: true,
maintainCase: true
}).should.eql('Sch(*-)ner-(love)-Ti-love-tel-love-laesst-gruessen!?-Bel-love-love-ete-!');
done();

@@ -164,0 +173,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