ffffng/server/utils/strings.js

23 lines
602 B
JavaScript
Raw Normal View History

2014-05-12 20:08:19 +02:00
'use strict';
angular.module('ffffng').factory('Strings', function (_) {
return {
normalizeString: function (str) {
return _.isString(str) ? str.trim().replace(/\s+/g, ' ') : str;
},
normalizeMac: function (mac) {
// parts only contains values at odd indexes
var parts = mac.toUpperCase().replace(/:/g, '').split(/([A-F0-9]{2})/);
var macParts = [];
for (var i = 1; i < parts.length; i += 2) {
macParts.push(parts[i]);
}
return macParts.join(':');
}
};
});