From bb61b823fcb4a6674e65aa114f475b888b333006 Mon Sep 17 00:00:00 2001 From: Nouman Tahir Date: Mon, 11 Oct 2021 12:03:09 +0500 Subject: [PATCH] moved post permalink processor outside web script it also now handles comment link from main post body --- src/components/postElements/body/view/config.js | 5 +---- .../postElements/body/view/postBodyView.js | 14 ++++++++++++++ 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/src/components/postElements/body/view/config.js b/src/components/postElements/body/view/config.js index 70b5a70d1..1ea056bd5 100644 --- a/src/components/postElements/body/view/config.js +++ b/src/components/postElements/body/view/config.js @@ -64,10 +64,7 @@ document.addEventListener('click', function(event) { var author = el.getAttribute('data-author'); var permlink = el.getAttribute('data-permlink'); - const queryIndex = permlink.lastIndexOf('?'); - if(queryIndex > -1){ - permlink = permlink.substring(0, queryIndex) - } + var result = { type: 'markdown-post-link', category: category, diff --git a/src/components/postElements/body/view/postBodyView.js b/src/components/postElements/body/view/postBodyView.js index 49937e6ea..dfe6d087e 100644 --- a/src/components/postElements/body/view/postBodyView.js +++ b/src/components/postElements/body/view/postBodyView.js @@ -212,6 +212,20 @@ const PostBody = ({ const _handleOnPostPress = (permlink, author) => { if (permlink) { + //snippets checks if there is anchored post inside permlink and use that instead + const anchoredPostRegex = /(.*?\#\@)(.*)\/(.*)/; + const matchedLink = permlink.match(anchoredPostRegex); + if (matchedLink) { + author = matchedLink[2]; + permlink = matchedLink[3]; + } + + //check if permlink has trailing query param, remove that if is the case + const queryIndex = permlink.lastIndexOf('?'); + if (queryIndex > -1) { + permlink = permlink.substring(0, queryIndex); + } + navigation.navigate({ routeName: ROUTES.SCREENS.POST, params: {