Merge pull request #1826 from Haendlerbund/18062-feature/improve-sluggable-logic

improve sluggable logic
This commit is contained in:
Jitendra Singh 2019-12-03 17:50:56 +05:30 committed by GitHub
commit 1b026bc913
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 16 additions and 8 deletions

3
.gitignore vendored
View File

@ -5,7 +5,6 @@
/public/js
/public/vendor
/public/themes
/storage/*.key
/vendor
/.idea
/.vscode
@ -21,3 +20,5 @@ yarn.lock
package-lock.json
yarn.lock
.php_cs.cache
storage/
storage/*.key

View File

@ -1,14 +1,21 @@
<script>
export default {
bind(el, binding, vnode) {
let handler = function(e) {
setTimeout(function() {
e.target.value = e.target.value.toString().toLowerCase()
.replace(/[^\w- ]+/g,'')
.trim()
.replace(/ +/g,'-');
let handler = function (e) {
setTimeout(function () {
e.target.value = e.target.value
.toString()
.toLowerCase()
.replace(/[^\w- ]+/g, '')
// replace whitespaces with dashes
.replace(/ +/g, '-')
// avoid having multiple dashes (---- translates into -)
.replace('![-\s]+!u', '-')
.trim();
}, 100);
}
};
el.addEventListener('input', handler);
}