parse deep link only if hostname matches (#6619)
This commit is contained in:
parent
335ec0c588
commit
9fd8781808
1 changed files with 6 additions and 4 deletions
|
|
@ -174,20 +174,22 @@ export function matchDeepLink(url?: string, serverURL?: string, siteURL?: string
|
|||
}
|
||||
|
||||
let urlToMatch = url;
|
||||
const urlBase = serverURL || siteURL || '';
|
||||
|
||||
if (!url.startsWith('mattermost://')) {
|
||||
// If url doesn't contain site or server URL, tack it on.
|
||||
// e.g. <jump to convo> URLs from autolink plugin.
|
||||
const urlBase = serverURL || siteURL || '';
|
||||
const match = new RegExp(escapeRegex(urlBase)).exec(url);
|
||||
if (!match) {
|
||||
urlToMatch = urlBase + url;
|
||||
}
|
||||
}
|
||||
|
||||
const parsedDeepLink = parseDeepLink(urlToMatch);
|
||||
if (parsedDeepLink.type !== DeepLink.Invalid) {
|
||||
return parsedDeepLink;
|
||||
if (urlParse(urlToMatch).hostname === urlParse(urlBase).hostname) {
|
||||
const parsedDeepLink = parseDeepLink(urlToMatch);
|
||||
if (parsedDeepLink.type !== DeepLink.Invalid) {
|
||||
return parsedDeepLink;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
|
|
|
|||
Loading…
Reference in a new issue