summaryrefslogtreecommitdiff
path: root/src/core/utils/slug.js
diff options
context:
space:
mode:
Diffstat (limited to 'src/core/utils/slug.js')
-rw-r--r--src/core/utils/slug.js18
1 files changed, 10 insertions, 8 deletions
diff --git a/src/core/utils/slug.js b/src/core/utils/slug.js
index fab37330..7010008a 100644
--- a/src/core/utils/slug.js
+++ b/src/core/utils/slug.js
@@ -1,15 +1,21 @@
import toTitleCase from './toTitleCase'
const createSlug = (prefix, name, id) => {
- let slug = name?.trim().replace(new RegExp(/[^A-Za-z0-9]/, 'g'), '-').toLowerCase() + '-' + id
+ let slug =
+ name
+ ?.trim()
+ .replace(new RegExp(/[^A-Za-z0-9]/, 'g'), '-')
+ .toLowerCase() +
+ '-' +
+ id
let splitSlug = slug.split('-')
- let filterSlugFromEmptyChar = splitSlug.filter(x => x != '')
+ let filterSlugFromEmptyChar = splitSlug.filter((x) => x != '')
return prefix + filterSlugFromEmptyChar.join('-')
}
const getIdFromSlug = (slug) => {
let id = slug.split('-')
- return id[id.length-1]
+ return id[id.length - 1]
}
const getNameFromSlug = (slug) => {
@@ -18,8 +24,4 @@ const getNameFromSlug = (slug) => {
return toTitleCase(name.join(' '))
}
-export {
- createSlug,
- getIdFromSlug,
- getNameFromSlug
-} \ No newline at end of file
+export { createSlug, getIdFromSlug, getNameFromSlug }