@@ -3,6 +3,8 @@ const AppRouter = require('./app-router');
33const { isNullOrUndefined } = require ( './utils' ) ;
44const { extend, isObject } = require ( 'underscore' ) ;
55
6+ const isCNApp = appId => appId . slice ( - 9 ) !== '-MdYXbMMI' ;
7+
68const fillServerURLs = url => ( {
79 push : url ,
810 stats : url ,
@@ -12,20 +14,11 @@ const fillServerURLs = url => ({
1214} ) ;
1315
1416function getDefaultServerURLs ( appId ) {
15- let domain ;
16- const id = appId . slice ( 0 , 8 ) . toLowerCase ( ) ;
17- switch ( appId . slice ( - 9 ) ) {
18- case '-9Nh9j0Va' :
19- // TAB
20- domain = 'lncldapi.com' ;
21- break ;
22- case '-MdYXbMMI' :
23- // US
24- domain = 'lncldglobal.com' ;
25- break ;
26- default :
27- domain = 'lncld.net' ;
17+ if ( isCNApp ( appId ) ) {
18+ return { } ;
2819 }
20+ const id = appId . slice ( 0 , 8 ) . toLowerCase ( ) ;
21+ const domain = 'lncldglobal.com' ;
2922 return {
3023 push : `https://${ id } .push.${ domain } ` ,
3124 stats : `https://${ id } .stats.${ domain } ` ,
@@ -82,6 +75,13 @@ AV.init = function init(options, ...params) {
8275 if ( ! appKey ) throw new TypeError ( 'appKey must be a string' ) ;
8376 if ( process . env . CLIENT_PLATFORM && masterKey )
8477 console . warn ( 'MasterKey is not supposed to be used in browser.' ) ;
78+ if ( isCNApp ( appId ) ) {
79+ if ( ! serverURLs ) {
80+ throw new TypeError (
81+ `serverURLs option is required for apps from CN region`
82+ ) ;
83+ }
84+ }
8585 AV . _config . applicationId = appId ;
8686 AV . _config . applicationKey = appKey ;
8787 AV . _config . masterKey = masterKey ;
0 commit comments