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-05-08 17:01:59 +02:00
|
|
|
//domain = "beta.covid-19.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-07-15 10:19:35 +02:00
|
|
|
domain = domain.substr(0, domain.indexOf('.'));
|
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
|
|
|
}
|