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

Split passphrase by selected index, not by selected word #1053

Merged
merged 1 commit into from
Jun 22, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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