From 2ee7ba5836e57f48a7153988e8419b97649f890f Mon Sep 17 00:00:00 2001 From: Mustafa Buyukcelebi Date: Thu, 21 Feb 2019 11:45:06 +0300 Subject: [PATCH] Fix for #527 --- .../postElements/body/view/postBodyView.js | 35 +++++++++++++++++-- 1 file changed, 32 insertions(+), 3 deletions(-) diff --git a/src/components/postElements/body/view/postBodyView.js b/src/components/postElements/body/view/postBodyView.js index d6293e357..8cfb53d40 100644 --- a/src/components/postElements/body/view/postBodyView.js +++ b/src/components/postElements/body/view/postBodyView.js @@ -32,7 +32,7 @@ class PostBody extends PureComponent { // Component Functions _handleOnLinkPress = (evt, href, hrefatr) => { - const { handleOnUserPress, handleOnPostPress, intl } = this.props; + const { handleOnUserPress, handleOnPostPress } = this.props; if (hrefatr.class === 'markdown-author-link') { if (!handleOnUserPress) { @@ -47,9 +47,38 @@ class PostBody extends PureComponent { handleOnPostPress(href); } } else { - Linking.canOpenURL(href).then((supported) => { + this._handleBrowserLink(href); + } + }; + + _handleBrowserLink = async (url) => { + if (!url) return; + + let author; + let permlink; + const { intl } = this.props; + + if ( + url.indexOf('esteem') > -1 + || url.indexOf('steemit') > -1 + || url.indexOf('busy') > -1 + || url.indexOf('steempeak') > -1 + ) { + url = url.substring(url.indexOf('@'), url.length); + const routeParams = url.indexOf('/') > -1 ? url.split('/') : [url]; + + [, permlink] = routeParams; + author = routeParams[0].indexOf('@') > -1 ? routeParams[0].replace('@', '') : routeParams[0]; + } + + if (author && permlink) { + this._handleOnPostPress(permlink, author); + } else if (author) { + this._handleOnUserPress(author); + } else { + Linking.canOpenURL(url).then((supported) => { if (supported) { - Linking.openURL(href); + Linking.openURL(url); } else { Alert.alert(intl.formatMessage({ id: 'alert.failed_to_open' })); }