2016-10-10 03:43:44 +02:00
|
|
|
'use strict';
|
|
|
|
module.exports = function () {
|
|
|
|
var str = [].map.call(arguments, function (str) {
|
|
|
|
return str.trim();
|
|
|
|
}).filter(function (str) {
|
|
|
|
return str.length;
|
|
|
|
}).join('-');
|
|
|
|
|
|
|
|
if (!str.length) {
|
|
|
|
return '';
|
|
|
|
}
|
|
|
|
|
2016-11-13 21:53:45 +01:00
|
|
|
if (str.length === 1 || !(/[_.\- ]+/).test(str) ) {
|
|
|
|
if (str[0] === str[0].toLowerCase() && str.slice(1) !== str.slice(1).toLowerCase()) {
|
|
|
|
return str;
|
2016-10-10 03:43:44 +02:00
|
|
|
}
|
|
|
|
|
2016-11-13 21:53:45 +01:00
|
|
|
return str.toLowerCase();
|
2016-10-10 03:43:44 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
return str
|
|
|
|
.replace(/^[_.\- ]+/, '')
|
|
|
|
.toLowerCase()
|
|
|
|
.replace(/[_.\- ]+(\w|$)/g, function (m, p1) {
|
|
|
|
return p1.toUpperCase();
|
|
|
|
});
|
|
|
|
};
|