argos/dmp-frontend/src/app/utilities/UrlUtilities.ts

18 lines
414 B
TypeScript
Raw Normal View History

2018-10-05 17:00:54 +02:00
import { Injectable } from '@angular/core';
2018-06-05 10:18:01 +02:00
@Injectable()
export class UrlUtilities {
2018-10-05 17:00:54 +02:00
public applyUrlTemplate(url: string, params: any): string {
let paramsToString = '';
if (params) { paramsToString = '?'; }
const keys = Object.keys(params);
keys.forEach(x => {
if (keys.indexOf(x) > 0) { paramsToString += '&'; }
paramsToString += x + '=' + params[x];
});
return url + paramsToString;
}
2018-06-05 10:18:01 +02:00
}