Skip to content

Commit

Permalink
fix(slugify): return non ASCII characters
Browse files Browse the repository at this point in the history
  • Loading branch information
14nrv committed Jul 7, 2019
1 parent d0bb97f commit 10f57ca
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/helpers/index.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
import slugify from 'slugify'

export const slug = str => slugify(str.toLowerCase())
export const slug = str => slugify(str.toLowerCase()) || str
16 changes: 16 additions & 0 deletions src/helpers/index.spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import { slug } from './'

describe('helpers', () => {
it('slugify string', () => {
expect(slug('First Name')).toBe('first-name')
})

it('slugify only ASCII characters', () => {
expect(slug('本社名 または 屋号 Company Name')).toBe('company-name')
})

it('return default string if non ASCII characters', () => {
const str = '本社名 または 屋号'
expect(slug(str)).toBe(str)
})
})

0 comments on commit 10f57ca

Please sign in to comment.