Skip to content

Commit

Permalink
Implemenst search by punycode (#197)
Browse files Browse the repository at this point in the history
Co-authored-by: Fernando Falci <fernando.falci@adevinta.com>
Co-authored-by: Chi Kei Chan <chikeichan@gmail.com>
  • Loading branch information
3 people authored Aug 7, 2020
1 parent 6b9fdca commit 799f7f2
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
3 changes: 2 additions & 1 deletion app/components/TLDInput/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { connect } from 'react-redux';
import c from 'classnames';
import * as nameActions from '../../ducks/names';
import { verifyName } from '../../utils/nameChecker';
import { decodePunycode } from '../../utils/nameHelpers';
import './TLDInput.scss';

@withRouter
Expand Down Expand Up @@ -39,7 +40,7 @@ class TLDInput extends Component {
};

handleSearchClick = () => {
const name = this.state.inputValue;
const name = decodePunycode(this.state.inputValue);

if (!name.length) {
return;
Expand Down
11 changes: 10 additions & 1 deletion app/utils/nameHelpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,15 @@ function checkState(name, expectedState) {
return info.state === expectedState;
}


export const decodePunycode = name => {
try {
return punycode.toASCII(name);
} catch(e) {}

return name;
}

export const formatName = name => {
if (!name)
return name;
Expand All @@ -89,4 +98,4 @@ export const formatName = name => {
} catch(e) {}

return `${name}/`;
}
}

0 comments on commit 799f7f2

Please sign in to comment.