Skip to content
This repository has been archived by the owner on Apr 15, 2019. It is now read-only.

Commit

Permalink
Merge pull request #1053 from webmaster128/split-by-index
Browse files Browse the repository at this point in the history
Split passphrase by selected index, not by selected word
  • Loading branch information
reyraa authored Jun 22, 2018
2 parents d592384 + 8dba98f commit 04849ba
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
5 changes: 4 additions & 1 deletion src/components/passphrase/passphraseVerifier.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,11 @@ class PassphraseConfirmator extends React.Component {
const words = this.props.passphrase.trim().split(/\s+/).filter(item => item.length > 0);
const index = Math.floor(rand * (words.length - 1));

const passphraseBeforeHiddenWord = words.slice(0, index).join(' ');
const passphraseAfterHiddenWord = words.slice(index + 1).join(' ');

this.setState({
passphraseParts: this.props.passphrase.split(words[index]),
passphraseParts: [passphraseBeforeHiddenWord, passphraseAfterHiddenWord],
missing: words[index],
answer: '',
});
Expand Down
4 changes: 2 additions & 2 deletions src/components/passphrase/passphraseVerifier.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,9 @@ describe('PassphraseVerifier', () => {

it('should break passphrase, hide a word and show it', () => {
const expectedValues = [
'survey stereo pool fortune oblige ',
'survey stereo pool fortune oblige',
'-----',
' gravity goddess mistake sentence anchor pool',
'gravity goddess mistake sentence anchor pool',
];
const spanTags = wrapper.find('.passphrase-holder span');

Expand Down

0 comments on commit 04849ba

Please sign in to comment.