From cc6e04ddf87fdcec5632de6967de710db4114253 Mon Sep 17 00:00:00 2001 From: Zoltan Bettenbuk Date: Wed, 4 Apr 2018 11:21:02 +0200 Subject: [PATCH] [RN] Fix calendar alerts when case sensitive URLs are used --- react/features/base/connection/functions.js | 18 ++++++++++++++++++ .../ConferenceNotification.native.js | 11 ++++++++--- 2 files changed, 26 insertions(+), 3 deletions(-) diff --git a/react/features/base/connection/functions.js b/react/features/base/connection/functions.js index 931535524..8a7a06d2b 100644 --- a/react/features/base/connection/functions.js +++ b/react/features/base/connection/functions.js @@ -52,6 +52,24 @@ export function getURLWithoutParams(url: URL): URL { return url; } +/** + * Gets a URL string without hash and query/search params from a specific + * {@code URL}. + * + * @param {URL} url - The {@code URL} which may have hash and query/search + * params. + * @returns {string} + */ +export function getURLWithoutParamsNormalized(url: URL): string { + const urlWithoutParams = getURLWithoutParams(url).href; + + if (urlWithoutParams) { + return urlWithoutParams.toLowerCase(); + } + + return ''; +} + /** * Converts a specific id to jid if it's not jid yet. * diff --git a/react/features/calendar-sync/components/ConferenceNotification.native.js b/react/features/calendar-sync/components/ConferenceNotification.native.js index ef5ba6df6..730d02751 100644 --- a/react/features/calendar-sync/components/ConferenceNotification.native.js +++ b/react/features/calendar-sync/components/ConferenceNotification.native.js @@ -8,7 +8,7 @@ import { import { connect } from 'react-redux'; import { appNavigate } from '../../app'; -import { getURLWithoutParams } from '../../base/connection'; +import { getURLWithoutParamsNormalized } from '../../base/connection'; import { getLocalizedDateFormatter, translate } from '../../base/i18n'; import { Icon } from '../../base/font-icons'; import { ASPECT_RATIO_NARROW } from '../../base/responsive-ui'; @@ -223,7 +223,11 @@ class ConferenceNotification extends Component { const now = Date.now(); for (const event of _eventList) { - if (event.url !== _currentConferenceURL) { + const eventUrl = getURLWithoutParamsNormalized( + new URL(event.url) + ); + + if (eventUrl !== _currentConferenceURL) { if ((!eventToShow && event.startDate > now && event.startDate < now + ALERT_MILLISECONDS) @@ -275,7 +279,8 @@ export function _mapStateToProps(state: Object) { return { _aspectRatio: state['features/base/responsive-ui'].aspectRatio, _currentConferenceURL: - locationURL ? getURLWithoutParams(locationURL)._url : '', + locationURL + ? getURLWithoutParamsNormalized(locationURL) : '', _eventList: state['features/calendar-sync'].events }; }