Merge branch 'master'
[arvados-workbench2.git] / src / common / api / url-builder.ts
1 // Copyright (C) The Arvados Authors. All rights reserved.
2 //
3 // SPDX-License-Identifier: AGPL-3.0
4
5 export class UrlBuilder {
6     private readonly url: string = "";
7     private query: string = "";
8
9     constructor(host: string) {
10         this.url = host;
11     }
12
13     public addParam(param: string, value: string) {
14         if (this.query.length === 0) {
15             this.query += "?";
16         } else {
17             this.query += "&";
18         }
19         this.query += `${param}=${value}`;
20         return this;
21     }
22
23     public get() {
24         return this.url + this.query;
25     }
26 }