From 917c2a809fe93b601a72ea299a99109e39b28c90 Mon Sep 17 00:00:00 2001 From: Nouman Tahir Date: Thu, 10 Jun 2021 11:28:00 +0500 Subject: [PATCH] added regex conditional for query parameters ignore if present --- src/utils/postUrlParser.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/utils/postUrlParser.js b/src/utils/postUrlParser.js index 2c14386e2..fdb5022e1 100644 --- a/src/utils/postUrlParser.js +++ b/src/utils/postUrlParser.js @@ -1,5 +1,5 @@ const parseCatAuthorPermlink = (u) => { - const postRegex = /^https?:\/\/(.*)\/(.*)\/(@[\w.\d-]+)\/(.*?)\?/i; + const postRegex = /^https?:\/\/(.*)\/(.*)\/(@[\w.\d-]+)\/(.*?)(?:\?|$)/i; const postMatch = u.match(postRegex); if (postMatch && postMatch.length === 5) { @@ -16,7 +16,7 @@ const parseCatAuthorPermlink = (u) => { permlink: null, }; } - const r = /^https?:\/\/(.*)\/(@[\w.\d-]+)\/(.*?)\?/i; + const r = /^https?:\/\/(.*)\/(@[\w.\d-]+)\/(.*?)(?:\?|$)/i; const match = u.match(r); if (match && match.length === 4) { @@ -29,7 +29,7 @@ const parseCatAuthorPermlink = (u) => { }; const parseAuthorPermlink = (u) => { - const r = /^https?:\/\/(.*)\/(@[\w.\d-]+)\/(.*?)\?/i; + const r = /^https?:\/\/(.*)\/(@[\w.\d-]+)\/(.*?)(?:\?|$)/i; const match = u.match(r); if (match && match.length === 4) { @@ -73,7 +73,7 @@ export default (url) => { } // For non urls like @good-karma/esteem-london-presentation-e3105ba6637ed - let match = url.match(/^[/]?(@[\w.\d-]+)\/(.*?)\?/); + let match = url.match(/^[/]?(@[\w.\d-]+)\/(.*?)(?:\?|$)/); if (match && match.length === 3) { return { author: match[1].replace('@', ''), @@ -82,7 +82,7 @@ export default (url) => { } // For non urls with category like esteem/@good-karma/esteem-london-presentation-e3105ba6637ed - match = url.match(/([\w.\d-]+)\/(@[\w.\d-]+)\/(.*?)\?/); + match = url.match(/([\w.\d-]+)\/(@[\w.\d-]+)\/(.*?)(?:\?|$)/); if (match && match.length === 4) { if (match[3].indexOf('#') > -1) { const commentPart = match[3].split('@')[1];