2018-10-07 07:51:58 +00:00
|
|
|
exports.dasherize = function dasherize(name) {
|
2016-06-24 03:05:30 +00:00
|
|
|
return ('' + name)
|
|
|
|
.toLowerCase()
|
|
|
|
.replace(/\s/g, '-')
|
2019-02-06 14:19:58 +00:00
|
|
|
.replace(/[^a-z0-9\-.]/gi, '')
|
|
|
|
.replace(/:/g, '');
|
|
|
|
};
|
2016-06-24 03:05:30 +00:00
|
|
|
|
2018-10-07 07:51:58 +00:00
|
|
|
exports.nameify = function nameify(str) {
|
2019-02-06 14:19:58 +00:00
|
|
|
return ('' + str).replace(/[^a-zA-Z0-9\s]/g, '').replace(/:/g, '');
|
|
|
|
};
|
2016-06-24 03:05:30 +00:00
|
|
|
|
2018-10-07 07:51:58 +00:00
|
|
|
exports.unDasherize = function unDasherize(name) {
|
2019-02-06 14:19:58 +00:00
|
|
|
return (
|
|
|
|
('' + name)
|
|
|
|
// replace dash with space
|
|
|
|
.replace(/-/g, ' ')
|
|
|
|
// strip nonalphanumarics chars except whitespace
|
|
|
|
.replace(/[^a-zA-Z\d\s]/g, '')
|
|
|
|
.trim()
|
|
|
|
);
|
|
|
|
};
|
2018-02-16 23:18:53 +00:00
|
|
|
|
2018-10-07 07:51:58 +00:00
|
|
|
exports.addPlaceholderImage = function addPlaceholderImage(name) {
|
2018-02-16 23:18:53 +00:00
|
|
|
return `https://identicon.org?t=${name}&s=256`;
|
2019-02-06 14:19:58 +00:00
|
|
|
};
|