Skip to content
This repository has been archived by the owner on Nov 6, 2020. It is now read-only.

Commit

Permalink
Don't return empty names as clickable titles (#2809)
Browse files Browse the repository at this point in the history
* Don't return empty names (Fixes #2786)

* add trim in validation
  • Loading branch information
jacogr authored Oct 25, 2016
1 parent 285727e commit 9f6da3f
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
8 changes: 5 additions & 3 deletions js/src/ui/IdentityName/identityName.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ import React, { Component, PropTypes } from 'react';
import { connect } from 'react-redux';
import { bindActionCreators } from 'redux';

const defaultName = 'UNNAMED';

class IdentityName extends Component {
static propTypes = {
address: PropTypes.string,
Expand All @@ -38,14 +40,14 @@ class IdentityName extends Component {
}

const addressFallback = shorten ? this.formatHash(address) : address;
const fallback = unknown ? 'UNNAMED' : addressFallback;
const fallback = unknown ? defaultName : addressFallback;
const isUuid = hasAccount && account.name === account.uuid;
const name = hasAccount && !isUuid
? account.name.toUpperCase()
? account.name.toUpperCase().trim()
: fallback;

return (
<span>{ name }</span>
<span>{ name && name.length ? name : fallback }</span>
);
}

Expand Down
2 changes: 1 addition & 1 deletion js/src/util/validation.js
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ export function validateCode (code, api) {
}

export function validateName (name) {
const nameError = !name || name.length < 2 ? ERRORS.invalidName : null;
const nameError = !name || name.trim().length < 2 ? ERRORS.invalidName : null;

return {
name,
Expand Down

0 comments on commit 9f6da3f

Please sign in to comment.