1
|
import {HttpParams} from '@angular/common/http';
|
2
|
|
3
|
export class ConnectHelper {
|
4
|
|
5
|
public static getCommunityFromDomain(domain: string): string{
|
6
|
// domain = "beta.egi.openaire.eu"; //for testing
|
7
|
if (domain.indexOf('openaire.eu') === -1) {
|
8
|
return null;
|
9
|
}
|
10
|
if ( domain.indexOf('beta') !== -1) {
|
11
|
domain = domain.substr(domain.indexOf('.') + 1, domain.length);
|
12
|
domain = domain.substr(0, domain.indexOf('.'));
|
13
|
} else if (domain.indexOf('test.') !== -1) {
|
14
|
return null;
|
15
|
} else {
|
16
|
domain = domain.substr(0, domain.indexOf('.'));
|
17
|
}
|
18
|
if (domain === 'connect' || domain === 'explore' || domain === 'monitor' || domain === 'admin'){
|
19
|
return null;
|
20
|
}
|
21
|
return domain;
|
22
|
}
|
23
|
|
24
|
public static getCommunityFromPath(path: string): string {
|
25
|
if (path.includes('?')) {
|
26
|
const httpParams = new HttpParams({ fromString: path.split('?')[1] });
|
27
|
return httpParams.get('communityId');
|
28
|
} else {
|
29
|
return null;
|
30
|
}
|
31
|
}
|
32
|
}
|