moved post permalink processor outside web script

it also now handles comment link from main post body
This commit is contained in:
Nouman Tahir 2021-10-11 12:03:09 +05:00
parent 6b11695e91
commit bb61b823fc
2 changed files with 15 additions and 4 deletions

View File

@ -64,10 +64,7 @@ document.addEventListener('click', function(event) {
var author = el.getAttribute('data-author'); var author = el.getAttribute('data-author');
var permlink = el.getAttribute('data-permlink'); var permlink = el.getAttribute('data-permlink');
const queryIndex = permlink.lastIndexOf('?');
if(queryIndex > -1){
permlink = permlink.substring(0, queryIndex)
}
var result = { var result = {
type: 'markdown-post-link', type: 'markdown-post-link',
category: category, category: category,

View File

@ -212,6 +212,20 @@ const PostBody = ({
const _handleOnPostPress = (permlink, author) => { const _handleOnPostPress = (permlink, author) => {
if (permlink) { 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({ navigation.navigate({
routeName: ROUTES.SCREENS.POST, routeName: ROUTES.SCREENS.POST,
params: { params: {