1 | 'use strict';
|
2 | module.exports = function () {
|
3 | var str = [].map.call(arguments, function (str) {
|
4 | return str.trim();
|
5 | }).filter(function (str) {
|
6 | return str.length;
|
7 | }).join('-');
|
8 |
|
9 | if (!str.length) {
|
10 | return '';
|
11 | }
|
12 |
|
13 | if (str.length === 1) {
|
14 | return str;
|
15 | }
|
16 |
|
17 | if (!(/[_.\- ]+/).test(str)) {
|
18 | if (str[0] === str[0].toLowerCase() && str.slice(1) !== str.slice(1).toLowerCase()) {
|
19 | return str;
|
20 | }
|
21 |
|
22 | return str.toLowerCase();
|
23 | }
|
24 |
|
25 | return str
|
26 | .replace(/^[_.\- ]+/, '')
|
27 | .toLowerCase()
|
28 | .replace(/[_.\- ]+(\w|$)/g, function (m, p1) {
|
29 | return p1.toUpperCase();
|
30 | });
|
31 | };
|