mirror of
https://github.com/BoostIo/Boostnote
synced 2025-12-13 17:56:25 +00:00
* Fix: 2-byte character support of slug * Fix: Decodes slug to display slug * Fix: Removed a logic of replaceDiacritics * Fix: Fixed slugify to pass tests * Fix: Fixed not to remove underscore * Adds the test for slugify.js * Fix: Fix to jump to heading * Added a comment * Fix: Created click event only linking to heading * Fix: Fix to use handleLinkClick(e) * Fix: Changed the regex rule * Fix: Changed the regex rule of extractId
12 lines
274 B
JavaScript
12 lines
274 B
JavaScript
module.exports = function slugify (title) {
|
|
const slug = encodeURI(
|
|
title.trim()
|
|
.replace(/^\s+/, '')
|
|
.replace(/\s+$/, '')
|
|
.replace(/\s+/g, '-')
|
|
.replace(/[\]\[\!\'\#\$\%\&\(\)\*\+\,\.\/\:\;\<\=\>\?\@\\\^\{\|\}\~\`]/g, '')
|
|
)
|
|
|
|
return slug
|
|
}
|