mirror of
https://github.com/freeCodeCamp/freeCodeCamp.git
synced 2026-01-06 06:01:31 -05:00
Co-authored-by: Muhammed Mustafa <muhammed@freecodecamp.org> Co-authored-by: ahmad abdolsaheb <ahmad.abdolsaheb@gmail.com> Co-authored-by: Muhammed Mustafa <MuhammedElruby@gmail.com>
27 lines
683 B
JavaScript
27 lines
683 B
JavaScript
'use strict';
|
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
exports.unDasherize = exports.nameify = exports.dasherize = void 0;
|
|
function dasherize(name) {
|
|
return ('' + name)
|
|
.toLowerCase()
|
|
.trim()
|
|
.replace(/\s|\./g, '-')
|
|
.replace(/[^a-z\d\-.]/g, '');
|
|
}
|
|
exports.dasherize = dasherize;
|
|
function nameify(str) {
|
|
return ('' + str).replace(/[^a-z\d\s]/gi, '');
|
|
}
|
|
exports.nameify = nameify;
|
|
function unDasherize(name) {
|
|
return (
|
|
('' + name)
|
|
// replace dash with space
|
|
.replace(/-/g, ' ')
|
|
// strip nonalphanumarics chars except whitespace
|
|
.replace(/[^a-z\d\s]/gi, '')
|
|
.trim()
|
|
);
|
|
}
|
|
exports.unDasherize = unDasherize;
|