-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathindex.js
More file actions
20 lines (14 loc) · 782 Bytes
/
index.js
File metadata and controls
20 lines (14 loc) · 782 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
// --------------------------------------------------------------------------------------------------------------------
'use strict'
// --------------------------------------------------------------------------------------------------------------------
function slugit(title) {
title = title || ''
title = title.toLowerCase().trim()
title = title.replace(/[\'\"]/g, '')
title = title.replace(/[^0-9A-Za-z]+/g, '-')
title = title.replace(/-+/g, '-').replace(/^-/, '').replace(/-$/, '')
return title
}
// --------------------------------------------------------------------------------------------------------------------
module.exports = slugit
// --------------------------------------------------------------------------------------------------------------------