2022-03-29 21:21:13 +05:30
|
|
|
function dasherize(name: string): string {
|
2019-09-25 20:16:08 +02:00
|
|
|
return ('' + name)
|
|
|
|
.toLowerCase()
|
2019-09-26 18:08:17 +02:00
|
|
|
.trim()
|
2020-07-03 16:58:53 +02:00
|
|
|
.replace(/\s|\./g, '-')
|
2019-09-26 16:27:26 +02:00
|
|
|
.replace(/[^a-z\d\-.]/g, '');
|
2022-03-29 21:21:13 +05:30
|
|
|
}
|
2019-09-25 20:16:08 +02:00
|
|
|
|
2022-03-29 21:21:13 +05:30
|
|
|
function nameify(str: string): string {
|
2019-09-26 16:27:26 +02:00
|
|
|
return ('' + str).replace(/[^a-z\d\s]/gi, '');
|
2022-03-29 21:21:13 +05:30
|
|
|
}
|
2019-09-25 20:16:08 +02:00
|
|
|
|
2022-03-29 21:21:13 +05:30
|
|
|
function unDasherize(name: string): string {
|
2019-09-25 20:16:08 +02:00
|
|
|
return (
|
|
|
|
('' + name)
|
|
|
|
// replace dash with space
|
|
|
|
.replace(/-/g, ' ')
|
|
|
|
// strip nonalphanumarics chars except whitespace
|
2019-09-26 16:27:26 +02:00
|
|
|
.replace(/[^a-z\d\s]/gi, '')
|
2019-09-25 20:16:08 +02:00
|
|
|
.trim()
|
|
|
|
);
|
2022-03-29 21:21:13 +05:30
|
|
|
}
|
|
|
|
|
|
|
|
export { dasherize, nameify, unDasherize };
|