import { Parameter } from './parameter.util';
import { HttpParams } from '@angular/common/http';

export class UrlUtil {
  public static format(href: string, param: Parameter): string {
    const params = param.toString();

    if (params.length === 0) {
      return href;
    } else {
      const qIdx = href.indexOf('?');
      const sep: string = qIdx === -1 ? '?' : qIdx < href.length - 1 ? '&' : '';
      return href + sep + params;
    }
  }
}
