mirror of
https://github.com/Mibew/mibew.git
synced 2025-01-31 05:20:30 +03:00
Improve Mibew.Utils.toDashFormat JS function
This commit is contained in:
parent
e273b04dab
commit
6d3810b7ba
@ -49,10 +49,17 @@
|
||||
if (typeof str != 'string') {
|
||||
return false;
|
||||
}
|
||||
var parts = str.match(/((?:[A-Z]?[a-z]+)|(?:[A-Z][a-z]*))/g);
|
||||
|
||||
var parts = str.match(/((?:[A-Z]?[a-z0-9]+)|(?:[A-Z][a-z0-9]*))/g);
|
||||
if (!parts) {
|
||||
// It seems that the sting has no convertible parts.
|
||||
return '';
|
||||
}
|
||||
|
||||
for(var i = 0; i < parts.length; i++) {
|
||||
parts[i] = parts[i].toLowerCase();
|
||||
}
|
||||
|
||||
return parts.join('-');
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user