Merge pull request #3599 from ethcore/jg-phrase-whitespace
Trim whitespace from input recovery phrase
This commit is contained in:
commit
d449b3c3f1
@ -54,8 +54,6 @@ export default class RecoveryPhrase extends Component {
|
|||||||
<Input
|
<Input
|
||||||
hint='the account recovery phrase'
|
hint='the account recovery phrase'
|
||||||
label='account recovery phrase'
|
label='account recovery phrase'
|
||||||
multiLine
|
|
||||||
rows={ 1 }
|
|
||||||
value={ recoveryPhrase }
|
value={ recoveryPhrase }
|
||||||
onChange={ this.onEditPhrase } />
|
onChange={ this.onEditPhrase } />
|
||||||
<Input
|
<Input
|
||||||
@ -112,17 +110,23 @@ export default class RecoveryPhrase extends Component {
|
|||||||
}
|
}
|
||||||
|
|
||||||
onEditPhrase = (event) => {
|
onEditPhrase = (event) => {
|
||||||
const value = event.target.value;
|
const recoveryPhrase = event.target.value
|
||||||
let error = null;
|
.toLowerCase() // wordlists are lowercase
|
||||||
|
.trim() // remove whitespace at both ends
|
||||||
|
.replace(/\s/g, ' ') // replace any whitespace with single space
|
||||||
|
.replace(/ +/g, ' '); // replace multiple spaces with a single space
|
||||||
|
|
||||||
if (!value || value.trim().length < 25) {
|
const parts = recoveryPhrase.split(' ');
|
||||||
error = ERRORS.noPhrase;
|
let recoveryPhraseError = null;
|
||||||
|
|
||||||
|
if (!recoveryPhrase || recoveryPhrase.length < 25 || parts.length < 8) {
|
||||||
|
recoveryPhraseError = ERRORS.noPhrase;
|
||||||
}
|
}
|
||||||
|
|
||||||
this.setState({
|
this.setState({
|
||||||
recoveryPhrase: value,
|
recoveryPhrase,
|
||||||
recoveryPhraseError: error,
|
recoveryPhraseError,
|
||||||
isValidPhrase: !error
|
isValidPhrase: !recoveryPhraseError
|
||||||
}, this.updateParent);
|
}, this.updateParent);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user