starter-blog/lib/utils/kebabCase.js
Timothy 735c954e72
Feat/sub-route (#38)
* blog subroute support
* docs: update readme and blog

Co-authored-by: mrhut10 <ahut10@gmail.com>
2021-05-08 13:58:57 +08:00

9 lines
197 B
JavaScript

const kebabCase = (str) =>
str &&
str
.match(/[A-Z]{2,}(?=[A-Z][a-z]+[0-9]*|\b)|[A-Z]?[a-z]+[0-9]*|[A-Z]|[0-9]+/g)
.map((x) => x.toLowerCase())
.join('-')
export default kebabCase