2019-02-27 11:39:13 +01:00
|
|
|
import {HttpParams} from '@angular/common/http';
|
2018-03-29 10:23:36 +02:00
|
|
|
|
2019-02-27 11:39:13 +01:00
|
|
|
export class ConnectHelper {
|
|
|
|
|
|
|
|
public static getCommunityFromDomain(domain: string): string{
|
2020-04-27 14:54:48 +02:00
|
|
|
//domain = "beta.fam.openaire.eu"; //for testing
|
2019-02-27 11:39:13 +01:00
|
|
|
if (domain.indexOf('openaire.eu') === -1) {
|
2018-03-29 10:23:36 +02:00
|
|
|
return null;
|
|
|
|
}
|
2019-02-27 11:39:13 +01:00
|
|
|
if ( domain.indexOf('beta') !== -1) {
|
|
|
|
domain = domain.substr(domain.indexOf('.') + 1, domain.length);
|
|
|
|
domain = domain.substr(0, domain.indexOf('.'));
|
|
|
|
} else if (domain.indexOf('test.') !== -1) {
|
2018-10-17 14:10:30 +02:00
|
|
|
return null;
|
2019-02-27 11:39:13 +01:00
|
|
|
} else {
|
2020-04-22 15:00:13 +02:00
|
|
|
//for production: ignore communities
|
|
|
|
// domain = domain.substr(0, domain.indexOf('.'));
|
|
|
|
return null;
|
2018-03-29 10:23:36 +02:00
|
|
|
}
|
2019-07-05 14:11:04 +02:00
|
|
|
if (domain === 'connect' || domain === 'explore' || domain === 'monitor' || domain === 'admin'){
|
2018-03-29 10:23:36 +02:00
|
|
|
return null;
|
|
|
|
}
|
|
|
|
return domain;
|
|
|
|
}
|
2019-02-27 11:39:13 +01:00
|
|
|
|
|
|
|
public static getCommunityFromPath(path: string): string {
|
|
|
|
if (path.includes('?')) {
|
|
|
|
const httpParams = new HttpParams({ fromString: path.split('?')[1] });
|
|
|
|
return httpParams.get('communityId');
|
|
|
|
} else {
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
}
|
2018-03-29 10:23:36 +02:00
|
|
|
}
|