Project

General

Profile

1 54915 k.triantaf
import {HttpParams} from '@angular/common/http';
2 51407 argiro.kok
3 54915 k.triantaf
export class ConnectHelper {
4
5
  public static  getCommunityFromDomain(domain: string): string{
6 58655 k.triantaf
    //domain = "beta.covid-19.openaire.eu"; //for testing
7 54915 k.triantaf
    if (domain.indexOf('openaire.eu') === -1) {
8 51407 argiro.kok
      return null;
9
    }
10 54915 k.triantaf
    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 53491 argiro.kok
      return null;
15 54915 k.triantaf
    } else {
16 58517 argiro.kok
      //for production: ignore communities
17
      // domain = domain.substr(0, domain.indexOf('.'));
18
      return null;
19 51407 argiro.kok
    }
20 56379 konstantin
    if (domain === 'connect' || domain === 'explore' || domain === 'monitor' || domain === 'admin'){
21 51407 argiro.kok
      return null;
22
    }
23
    return domain;
24
  }
25 54915 k.triantaf
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 51407 argiro.kok
}