You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
27 lines
550 B
27 lines
550 B
'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 ''; |
|
} |
|
|
|
if (str.length === 1 || !(/[_.\- ]+/).test(str) ) { |
|
if (str[0] === str[0].toLowerCase() && str.slice(1) !== str.slice(1).toLowerCase()) { |
|
return str; |
|
} |
|
|
|
return str.toLowerCase(); |
|
} |
|
|
|
return str |
|
.replace(/^[_.\- ]+/, '') |
|
.toLowerCase() |
|
.replace(/[_.\- ]+(\w|$)/g, function (m, p1) { |
|
return p1.toUpperCase(); |
|
}); |
|
};
|
|
|