Skip to content

Commit

Permalink
fix(ui): strip port out of ipv6 correctly when using lndconnect
Browse files Browse the repository at this point in the history
  • Loading branch information
korhaliv committed May 24, 2019
1 parent 16ce137 commit e71e469
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion renderer/components/Onboarding/Steps/ConnectionConfirm.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,24 @@ import { FormattedMessage } from 'react-intl'
import encode from 'lndconnect/encode'
import decode from 'lndconnect/decode'
import parseConnectionString from '@zap/utils/btcpayserver'
import { isIpV6, stripIpV6Port } from '@zap/utils/ipv6'

import { Bar, Form, Header, Span, Text } from 'components/UI'
import messages from './messages'

/**
* Removes port from a host string
*
* @param {string} host
* @returns host without a port part
*/
function sanitizeHost(host) {
if (isIpV6(host)) {
return stripIpV6Port(host)
}
return host.split(':')[0]
}

class ConnectionConfirm extends React.Component {
static propTypes = {
connectionCert: PropTypes.string,
Expand Down Expand Up @@ -165,7 +180,7 @@ class ConnectionConfirm extends React.Component {
<>
<Text>
<FormattedMessage {...messages.verify_host_title} />{' '}
<Span color="superGreen">{hostname.split(':')[0]}</Span>?{' '}
<Span color="superGreen">{sanitizeHost(hostname)}</Span>?{' '}
</Text>
<Text mt={2}>
<FormattedMessage {...messages.verify_host_description} />
Expand Down

0 comments on commit e71e469

Please sign in to comment.