Files
freeCodeCamp/utils/slugs.js
B.yashwanth 45c8d14b44 feat: add share in twitter button to the end of project. (#49395)
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>
2023-07-21 11:24:52 +03:00

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;