Project

General

Profile

1
import {HttpParams} from '@angular/common/http';
2

    
3
export class ConnectHelper {
4

    
5
  public static  getCommunityFromDomain(domain: string): string{
6
    domain = "beta.ee.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
      //for production: ignore communities
17
      // domain = domain.substr(0, domain.indexOf('.'));
18
      return null;
19
    }
20
    if (domain === 'connect' || domain === 'explore' || domain === 'monitor' || domain === 'admin'){
21
      return null;
22
    }
23
    return domain;
24
  }
25

    
26
  public static getCommunityFromPath(path: string): string {
27
    if (path.includes('?')) {
28
      const httpParams = new HttpParams({ fromString: path.split('?')[1] });
29
      return httpParams.get('communityId');
30
    } else {
31
      return null;
32
    }
33
  }
34
}
    (1-1/1)