Permalink
Browse files

Merge pull request #71 from laurensclaessen/trim-slugified-result

Trim dashes after slugification
  • Loading branch information...
dleitee committed Oct 31, 2017
2 parents a592ca3 + a459d34 commit a29bbc475341443267ae57adb64b89c810d065ef
Showing with 4 additions and 3 deletions.
  1. +3 −2 src/slugify.js
  2. +1 −1 test/slugify.test.js
View
@@ -35,6 +35,7 @@ export default (value) => {
const valueWithoutSpaces = removeSpaces(trimValue, '-')
const valueWithE = replace(valueWithoutSpaces, '&', '-and-')
const transliterateValue = transliterate(valueWithE)
const replaceValue = replace(transliterateValue, '[^\\w\\-]+', '')
return replace(replaceValue, '-+', '-')
const wordsOnlyValue = replace(transliterateValue, '[^\\w\\-]+', '')
const singleDashesValue = replace(wordsOnlyValue, '-+', '-')
return trim(singleDashesValue, '-')
}
View
@@ -2,7 +2,7 @@ import slugify from '../src/slugify'
describe('strman.slugfiy', () => {
test('should be foo-bar', () => {
const fixtures = ['foo bar', 'foo bar.', 'foo bar ', ' foo bar', ' foo bar ', 'foo------bar', 'fóõ bár', 'foo ! bar', 'foo ~~ bar', 'foo bar', 'FOO bar']
const fixtures = ['foo bar', 'foo bar.', 'foo bar ', 'foo bar .', ' foo bar', ' foo bar ', 'foo------bar', 'fóõ bár', 'foo ! bar', 'foo ~~ bar', 'foo bar', 'FOO bar']
fixtures.forEach((el) => {
expect(slugify(el)).toBe('foo-bar')

0 comments on commit a29bbc4

Please sign in to comment.