Browse Source

Add support for app link scheme

j8
zbettenbuk 7 years ago
parent
commit
c84abd543e
2 changed files with 17 additions and 4 deletions
  1. 7
    1
      react/features/base/util/uri.js
  2. 10
    3
      react/features/calendar-sync/middleware.js

+ 7
- 1
react/features/base/util/uri.js View File

@@ -1,5 +1,11 @@
1 1
 // @flow
2 2
 
3
+/**
4
+ * The app linking scheme.
5
+ * TODO: This should be read from the manifest files later.
6
+ */
7
+export const APP_LINK_SCHEME = 'org.jitsi.meet:';
8
+
3 9
 /**
4 10
  * The {@link RegExp} pattern of the authority of a URI.
5 11
  *
@@ -395,7 +401,7 @@ export function urlObjectToString(o: Object): ?string {
395 401
                     // XXX The value of domain in supposed to be host/hostname
396 402
                     // and, optionally, pathname. Make sure it is not taken for
397 403
                     // a pathname only.
398
-                    _fixURIStringScheme(`org.jitsi.meet://${domain}`));
404
+                    _fixURIStringScheme(`${APP_LINK_SCHEME}//${domain}`));
399 405
 
400 406
             // authority
401 407
             if (host) {

+ 10
- 3
react/features/calendar-sync/middleware.js View File

@@ -4,7 +4,7 @@ import RNCalendarEvents from 'react-native-calendar-events';
4 4
 
5 5
 import { SET_ROOM } from '../base/conference';
6 6
 import { MiddlewareRegistry } from '../base/redux';
7
-import { parseURIString } from '../base/util';
7
+import { APP_LINK_SCHEME, parseURIString } from '../base/util';
8 8
 
9 9
 import { APP_WILL_MOUNT } from '../app';
10 10
 
@@ -161,8 +161,13 @@ function _fetchCalendarEntries(store) {
161 161
  *
162 162
  */
163 163
 function _getURLFromEvent(event, knownDomains) {
164
+    const linkTerminatorPattern = '[^\\s<>$]';
165
+    /* eslint-disable max-len */
164 166
     const urlRegExp
165
-        = new RegExp(`http(s)?://(${knownDomains.join('|')})/[^\\s<>$]+`, 'gi');
167
+        = new RegExp(`http(s)?://(${knownDomains.join('|')})/${linkTerminatorPattern}+`, 'gi');
168
+    /* eslint-enable max-len */
169
+    const schemeRegExp
170
+        = new RegExp(`${APP_LINK_SCHEME}${linkTerminatorPattern}+`, 'gi');
166 171
     const fieldsToSearch = [
167 172
         event.title,
168 173
         event.url,
@@ -175,7 +180,9 @@ function _getURLFromEvent(event, knownDomains) {
175 180
     for (const field of fieldsToSearch) {
176 181
         if (typeof field === 'string') {
177 182
             if (
178
-                (matchArray = urlRegExp.exec(field)) !== null
183
+                (matchArray
184
+                    = urlRegExp.exec(field) || schemeRegExp.exec(field))
185
+                        !== null
179 186
             ) {
180 187
                 return matchArray[0];
181 188
             }

Loading…
Cancel
Save