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

slug

Package Overview
Dependencies
Maintainers
1
Versions
74
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

slug - npm Package Compare versions

Comparing version 0.2.2 to 0.3.0

test.js

52

lib/slug.js
(function() {
var char_map, removelist, slug, symbols, word;
symbols = require('unicode/category/So');
removelist = ['sign', 'cross', 'of', 'symbol', 'staff'];
removelist = (function() {

@@ -14,2 +17,3 @@ var _i, _len, _results;

})();
char_map = {

@@ -156,8 +160,2 @@ 'À': 'A',

'İ': 'I',
'ç': 'c',
'Ç': 'C',
'ü': 'u',
'Ü': 'U',
'ö': 'o',
'Ö': 'O',
'ğ': 'g',

@@ -262,3 +260,2 @@ 'Ğ': 'G',

'ń': 'n',
'ó': 'o',
'ś': 's',

@@ -276,3 +273,2 @@ 'ź': 'z',

'ā': 'a',
'č': 'c',
'ē': 'e',

@@ -284,7 +280,4 @@ 'ģ': 'g',

'ņ': 'n',
'š': 's',
'ū': 'u',
'ž': 'z',
'Ā': 'A',
'Č': 'C',
'Ē': 'E',

@@ -296,5 +289,3 @@ 'Ģ': 'G',

'Ņ': 'N',
'Š': 'S',
'Ū': 'u',
'Ž': 'Z',
'€': 'euro',

@@ -357,9 +348,25 @@ '₢': 'cruzeiro',

};
module.exports = slug = function(string, replacement) {
var char, code, i, result, unicode, word, _i, _len, _len2;
if (replacement == null) {
replacement = '-';
module.exports = slug = function(string, opts) {
var char, code, i, result, unicode, _i, _j, _len, _len1;
if (opts == null) {
opts = {};
}
if ('string' === typeof opts) {
opts = {
replacement: opts
};
} else if ('boolean' === typeof opts) {
opts = {
lowerCase: opts
};
}
if (opts.replacement == null) {
opts.replacement = '-';
}
result = "";
for (i = 0, _len = string.length; i < _len; i++) {
if (opts.lowerCase) {
string = string.toLowerCase();
}
for (i = _i = 0, _len = string.length; _i < _len; i = ++_i) {
char = string[i];

@@ -374,4 +381,4 @@ code = string.charCodeAt(i);

char = unicode.name.toLowerCase();
for (_i = 0, _len2 = removelist.length; _i < _len2; _i++) {
word = removelist[_i];
for (_j = 0, _len1 = removelist.length; _j < _len1; _j++) {
word = removelist[_j];
char = char.replace(word, '');

@@ -385,5 +392,6 @@ }

result = result.replace(/^\s+|\s+$/g, '');
result = result.replace(/[-\s]+/g, replacement);
return result.replace("" + replacement + "$", '');
result = result.replace(/[-\s]+/g, opts.replacement);
return result.replace("" + opts.replacement + "$", '');
};
}).call(this);
{ "name": "slug"
, "description": "slugifies even utf-8 chars!"
, "version": "0.2.2"
, "version": "0.3.0"
, "homepage": "https://github.com/dodo/node-slug"

@@ -5,0 +5,0 @@ , "author": "dodo (https://github.com/dodo)"

Sorry, the diff of this file is not supported yet

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