Exclude static jitsi links from calendar fetch

pull/3649/head jitsi-meet_3427
Bettenbuk Zoltan 6 years ago committed by Zoltan Bettenbuk
parent 65519ec926
commit 4da8c626f7
  1. 40
      react/features/calendar-sync/functions.any.js

@ -96,6 +96,30 @@ export function _updateCalendarEntries(events: Array<Object>) {
.slice(0, MAX_LIST_LENGTH)));
}
/**
* Checks a string against a positive pattern and a negative pattern. Returns
* the string if it matches the positive pattern and doesn't provide any match
* against the negative pattern. Null otherwise.
*
* @param {string} str - The string to check.
* @param {string} positivePattern - The positive pattern.
* @param {string} negativePattern - The negative pattern.
* @returns {string}
*/
function _checkPattern(str, positivePattern, negativePattern) {
const positiveRegExp = new RegExp(positivePattern, 'gi');
let positiveMatch;
while ((positiveMatch = positiveRegExp.exec(str)) !== null) {
// $FlowFixMe
const url = positiveMatch[0];
if (!new RegExp(negativePattern, 'gi').exec(url)) {
return url;
}
}
}
/**
* Updates the calendar entries in Redux when new list is received.
*
@ -155,11 +179,9 @@ function _parseCalendarEntry(event, knownDomains) {
function _getURLFromEvent(event, knownDomains) {
const linkTerminatorPattern = '[^\\s<>$]';
const urlRegExp
= new RegExp(
`http(s)?://(${knownDomains.join('|')})/${linkTerminatorPattern}+`,
'gi');
const schemeRegExp
= new RegExp(`${APP_LINK_SCHEME}${linkTerminatorPattern}+`, 'gi');
= `http(s)?://(${knownDomains.join('|')})/${linkTerminatorPattern}+`;
const schemeRegExp = `${APP_LINK_SCHEME}${linkTerminatorPattern}+`;
const excludePattern = '/static/';
const fieldsToSearch = [
event.title,
event.url,
@ -170,10 +192,12 @@ function _getURLFromEvent(event, knownDomains) {
for (const field of fieldsToSearch) {
if (typeof field === 'string') {
const matches = urlRegExp.exec(field) || schemeRegExp.exec(field);
const match
= _checkPattern(field, urlRegExp, excludePattern)
|| _checkPattern(field, schemeRegExp, excludePattern);
if (matches) {
const url = parseURIString(matches[0]);
if (match) {
const url = parseURIString(match);
if (url) {
return url.toString();

Loading…
Cancel
Save