Skip to content

Commit

Permalink
Fix support for iconv when checking spelling
Browse files Browse the repository at this point in the history
Closes GH-13.
Closes GH-14.
  • Loading branch information
wooorm authored Mar 8, 2019
1 parent 180b384 commit a55923e
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 2 deletions.
3 changes: 3 additions & 0 deletions lib/util/form.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
'use strict'

var normalize = require('./normalize.js')
var trim = require('./trim.js')
var exact = require('./exact.js')
var flag = require('./flag.js')
Expand All @@ -18,6 +19,8 @@ function form(context, value, all) {
return null
}

value = normalize(value, context.conversion.in)

if (exact(context, value)) {
if (!all && flag(flags, 'FORBIDDENWORD', dict[value])) {
return null
Expand Down
33 changes: 31 additions & 2 deletions test/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -502,9 +502,38 @@ test('broken dictionaries', function(t) {
})

test('parse dictionaries', function(t) {
t.plan(1)
t.plan(2)

t.test('iconv and oconv', function(st) {
var dic = ['2', 'ijdel', 'ijdeltuit'].join('\n')
var aff = [
'SET UTF-8',
'',
'ICONV 1',
'ICONV ij ij',
'',
'OCONV 1',
'OCONV ij ij'
].join('\n')
var spell = nspell(aff + '\n', dic + '\n')

t.test('nspell#spell(value)', function(st) {
st.equal(spell.correct('ijdel'), true, 'should support iconv (#1)')
st.equal(spell.correct('ijdel'), true, 'should support iconv (#2)')
st.deepEqual(
spell.suggest('ijde'),
['ijdel', 'IJdel'],
'should support oconv (#1)'
)
st.deepEqual(
spell.suggest('ijde'),
['ijdel', 'IJdel'],
'should support oconv (#2)'
)

st.end()
})

t.test('slashes and comments', function(st) {
var dic = [
'5',
'aaa\\//A',
Expand Down

0 comments on commit a55923e

Please sign in to comment.