Procházet zdrojové kódy

Fix a daft mistake, blank out whitelisted words, rather than remove

This had caused an issue whereby spelling-mistakes would be highlighted
on the wrong word in the client. This was a function of how many whitelisted
words had already occured in the sequence. An off-by-n error.
Shane Kilkelly před 9 roky
rodič
revize
407283ee3c

+ 6 - 2
services/spelling/app/coffee/SpellingAPIManager.coffee

@@ -23,8 +23,12 @@ module.exports = SpellingAPIManager =
 			ASpell.checkWords lang, words, (error, misspellings) ->
 				callback error, misspellings: misspellings
 
-		wordsToCheck = (request.words || []).filter (word) ->
-			SpellingAPIManager.wordWhitelist.indexOf(word) == -1
+		wordsToCheck = (request.words || []).map (word) ->
+			# blank out whitelisted words
+			if SpellingAPIManager.wordWhitelist.indexOf(word) == -1
+				word
+			else
+				'...'
 
 		if token?
 			LearnedWordsManager.getLearnedWords token, (error, learnedWords) ->

+ 1 - 1
services/spelling/test/unit/coffee/SpellingAPIManagerTests.coffee

@@ -89,7 +89,7 @@ describe "SpellingAPIManager", ->
 				@SpellingAPIManager.runRequest @token, words: @words, (error, @result) => done()
 
 			it 'should ignore the white-listed word', ->
-				expect(@ASpell.checkWords.lastCall.args[1]).to.deep.equal ["One", "Two"]
+				expect(@ASpell.checkWords.lastCall.args[1]).to.deep.equal ["One", "...", "Two"]
 
 	describe "learnWord", ->
 		describe "without a token", ->