1 // Copyright (C) The Arvados Authors. All rights reserved.
3 // SPDX-License-Identifier: AGPL-3.0
5 export class UrlBuilder {
6 private readonly url: string = "";
7 private query: string = "";
9 constructor(host: string) {
13 public addParam(param: string, value: string) {
14 if (this.query.length === 0) {
19 this.query += `${param}=${value}`;
24 return this.url + this.query;
28 export function joinUrls(url0?: string, url1?: string) {
31 let idx0 = url0.length - 1;
32 while (url0[idx0] === '/') { --idx0; }
33 u0 = url0.substr(0, idx0 + 1);
38 while (url1[idx1] === '/') { ++idx1; }
39 u1 = url1.substr(idx1);