Skip to content

armgit / mocha

Public Imported from GitHub
0

☕️ Classic, reliable, trusted test framework for Node.js and the browser

added slug util

TJ Holowaychuk8b54154aaf80
diff --git a/lib/utils.js b/lib/utils.js
index 93e9d6df..22a942ec 100644
--- a/lib/utils.js
+++ b/lib/utils.js
@@ -172,4 +172,18 @@ exports.files = function(dir, ret){
});
return ret;
+};
+
+/**
+ * Compute a slug from the given `str`.
+ *
+ * @param {String} str
+ * @return {String}
+ */
+
+exports.slug = function(str){
+ return str
+ .toLowerCase()
+ .replace(/ +/g, '-')
+ .replace(/[^-\w]/g, '');
};
\ No newline at end of file