4
4
5
5
import cache from './cache' ;
6
6
7
+ function removeTrailingSlash ( str ) {
8
+ if ( ! str ) {
9
+ return str ;
10
+ }
11
+ if ( str . endsWith ( "/" ) ) {
12
+ str = str . substr ( 0 , str . length - 1 ) ;
13
+ }
14
+ return str ;
15
+ }
16
+
7
17
export class Config {
8
18
constructor ( applicationId : string , mount : string ) {
9
19
let DatabaseAdapter = require ( './DatabaseAdapter' ) ;
@@ -24,7 +34,7 @@ export class Config {
24
34
this . database = DatabaseAdapter . getDatabaseConnection ( applicationId , cacheInfo . collectionPrefix ) ;
25
35
26
36
this . serverURL = cacheInfo . serverURL ;
27
- this . publicServerURL = cacheInfo . publicServerURL ;
37
+ this . publicServerURL = removeTrailingSlash ( cacheInfo . publicServerURL ) ;
28
38
this . verifyUserEmails = cacheInfo . verifyUserEmails ;
29
39
this . appName = cacheInfo . appName ;
30
40
@@ -35,7 +45,7 @@ export class Config {
35
45
this . userController = cacheInfo . userController ;
36
46
this . authDataManager = cacheInfo . authDataManager ;
37
47
this . customPages = cacheInfo . customPages || { } ;
38
- this . mount = mount ;
48
+ this . mount = removeTrailingSlash ( mount ) ;
39
49
this . liveQueryController = cacheInfo . liveQueryController ;
40
50
}
41
51
@@ -56,6 +66,18 @@ export class Config {
56
66
}
57
67
}
58
68
69
+ get mount ( ) {
70
+ var mount = this . _mount ;
71
+ if ( this . publicServerURL ) {
72
+ mount = this . publicServerURL ;
73
+ }
74
+ return mount ;
75
+ }
76
+
77
+ set mount ( newValue ) {
78
+ this . _mount = newValue ;
79
+ }
80
+
59
81
get invalidLinkURL ( ) {
60
82
return this . customPages . invalidLink || `${ this . publicServerURL } /apps/invalid_link.html` ;
61
83
}
0 commit comments