34 lines
1.1 KiB
TypeScript
34 lines
1.1 KiB
TypeScript
import {HttpParams} from '@angular/common/http';
|
|
|
|
export class ConnectHelper {
|
|
|
|
public static getCommunityFromDomain(domain: string): string{
|
|
// domain = "https://mes.openaire.eu"; //for testing
|
|
domain = domain.indexOf("//") != -1? domain.split("//")[1]:domain; //remove https:// prefix
|
|
if (domain.indexOf('openaire.eu') === -1) {
|
|
return null;
|
|
}
|
|
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) {
|
|
return null;
|
|
} else {
|
|
domain = domain.substr(0, domain.indexOf('.'));
|
|
}
|
|
if (domain === 'connect' || domain === 'explore' || domain === 'monitor' || domain === 'admin'){
|
|
return null;
|
|
}
|
|
return domain;
|
|
}
|
|
|
|
public static getCommunityFromPath(path: string): string {
|
|
if (path.includes('?')) {
|
|
const httpParams = new HttpParams({ fromString: path.split('?')[1] });
|
|
return httpParams.get('communityId');
|
|
} else {
|
|
return null;
|
|
}
|
|
}
|
|
}
|