UNPKG

@zkochan/pnpm

Version:

A fast implementation of npm install

21 lines (17 loc) 452 B
'use strict' const parameterize = require('slugify') /** * Turns a string into a normalized string that can be used for a CSS * id/classname. * * slugify('/foo/bar.html') * //=> 'foo-bar' */ module.exports = function slugify (str) { str = str.toLowerCase() str = str.replace(/\/index.html$/, '') str = str.replace(/.html$/, '') str = parameterize(str) str = str.replace(/[^a-zA-Z0-9\-_]/g, '') if (str.length) return str }