Code coverage report for master/slugify.js

Statements: 100% (10 / 10)      Branches: 50% (1 / 2)      Functions: 100% (2 / 2)      Lines: 100% (10 / 10)      Ignored: none     

All files » master/ » slugify.js
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 181 1 1 1   1 8       8 16 16     8    
var makeString = require('./helper/makeString');
var defaultToWhiteSpace = require('./helper/defaultToWhiteSpace');
var trim = require('./trim');
var dasherize = require('./dasherize');
 
module.exports = function slugify(str) {
  var from  = "ąàáäâãåæăćčĉęèéëêĝĥìíïîĵłľńňòóöőôõðøśșšŝťțŭùúüűûñÿýçżźž",
      to    = "aaaaaaaaaccceeeeeghiiiijllnnoooooooossssttuuuuuunyyczzz",
      regex = new RegExp(defaultToWhiteSpace(from), 'g');
 
  str = makeString(str).toLowerCase().replace(regex, function(c){
    var index = from.indexOf(c);
    return to.charAt(index) || '-';
  });
 
  return trim(dasherize(str.replace(/[^\w\s-]/g, '-')), '-');
};