Skip to content

Commit

Permalink
New slugify function
Browse files Browse the repository at this point in the history
  • Loading branch information
David-Esteves committed Aug 24, 2018
1 parent c6dedbc commit 777ada8
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 16 deletions.
8 changes: 1 addition & 7 deletions arctic/static/arctic/dist/assets/js/app.js

Large diffs are not rendered by default.

9 changes: 0 additions & 9 deletions arctic/static/arctic/src/assets/js/utils/helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,23 +37,14 @@ window.arctic.utils = {
},

slugify: function ( text ) {
return text
.toLowerCase()
.replace( /[^\w ]+/g, '' )
.replace( / +/g, '-' );
},

slugify2: function ( text ) {
text = text.toLowerCase();
console.log(text)

// remove accents, swap ñ for n, etc
let from = 'àáäâèéëêìíïîòóöôùúüûñç';
let to = 'aaaaeeeeiiiioooouuuunc';
for (let i=0, l=from.length ; i<l ; i++) {
text = text.replace(new RegExp(from.charAt(i), 'g'), to.charAt(i));
}
console.log(text);
return text
.replace( /[^\w ]+/g, '' )
.replace( / +/g, '-' );
Expand Down

0 comments on commit 777ada8

Please sign in to comment.