diff options
| author | IT Fixcomart <it@fixcomart.co.id> | 2022-10-31 16:31:56 +0700 |
|---|---|---|
| committer | IT Fixcomart <it@fixcomart.co.id> | 2022-10-31 16:31:56 +0700 |
| commit | d6d2d9ceef2e95b604ac4ebdc054cad44a8440b1 (patch) | |
| tree | 376278eb3f7baa6b9405177b8fb57805d4a066b9 /src/helpers/slug.js | |
| parent | 97c98e0a6fa0757e58ca9dacf8e720a52e10dcf5 (diff) | |
Product detail and header
Diffstat (limited to 'src/helpers/slug.js')
| -rw-r--r-- | src/helpers/slug.js | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/src/helpers/slug.js b/src/helpers/slug.js new file mode 100644 index 00000000..5a8db08f --- /dev/null +++ b/src/helpers/slug.js @@ -0,0 +1,13 @@ +const createSlug = (name, id) => { + return name.trim().replace(new RegExp(/[^A-Za-z0-9]/, 'g'), '-').toLowerCase() + '-' + id; +} + +const getId = (slug) => { + let id = slug.split('-'); + return id[id.length-1]; +} + +export { + createSlug, + getId +};
\ No newline at end of file |
