private/apigen: fix URL construction in generated TypeScript code
This change fixes an incorrect invocation of the URL object constructor in generated TypeScript HTTP clients. Change-Id: I9011bc535f2096374d20b74b401d4cc38a0451fb
This commit is contained in:
parent
cfb7f55220
commit
032faefa4b
@ -114,7 +114,7 @@ export class DocumentsHttpApiV0 {
|
||||
}
|
||||
|
||||
public async updateContent(request: DocsUpdateContentRequest, path: string, id: UUID, date: Time): Promise<DocsUpdateContentResponse> {
|
||||
const u = new URL(`${this.ROOT_PATH}/${path}`);
|
||||
const u = new URL(`${this.ROOT_PATH}/${path}`, window.location.href);
|
||||
u.searchParams.set('id', id);
|
||||
u.searchParams.set('date', date);
|
||||
const fullPath = u.toString();
|
||||
|
@ -114,7 +114,7 @@ func (f *tsGenFile) createAPIClient(group *EndpointGroup) {
|
||||
|
||||
f.pf("\tpublic async %s(%s): Promise<%s> {", method.TypeScriptName, funcArgs, returnType)
|
||||
if len(method.QueryParams) > 0 {
|
||||
f.pf("\t\tconst u = new URL(`%s`);", path)
|
||||
f.pf("\t\tconst u = new URL(`%s`, window.location.href);", path)
|
||||
for _, p := range method.QueryParams {
|
||||
f.pf("\t\tu.searchParams.set('%s', %s);", p.Name, p.Name)
|
||||
}
|
||||
|
@ -148,7 +148,7 @@ export class ProjectManagementHttpApiV0 {
|
||||
}
|
||||
|
||||
public async getBucketRollup(projectID: UUID, bucket: string, since: Time, before: Time): Promise<BucketUsageRollup> {
|
||||
const u = new URL(`${this.ROOT_PATH}/bucket-rollup`);
|
||||
const u = new URL(`${this.ROOT_PATH}/bucket-rollup`, window.location.href);
|
||||
u.searchParams.set('projectID', projectID);
|
||||
u.searchParams.set('bucket', bucket);
|
||||
u.searchParams.set('since', since);
|
||||
@ -163,7 +163,7 @@ export class ProjectManagementHttpApiV0 {
|
||||
}
|
||||
|
||||
public async getBucketRollups(projectID: UUID, since: Time, before: Time): Promise<BucketUsageRollup[]> {
|
||||
const u = new URL(`${this.ROOT_PATH}/bucket-rollups`);
|
||||
const u = new URL(`${this.ROOT_PATH}/bucket-rollups`, window.location.href);
|
||||
u.searchParams.set('projectID', projectID);
|
||||
u.searchParams.set('since', since);
|
||||
u.searchParams.set('before', before);
|
||||
@ -177,7 +177,7 @@ export class ProjectManagementHttpApiV0 {
|
||||
}
|
||||
|
||||
public async getAPIKeys(projectID: UUID, search: string, limit: number, page: number, order: number, orderDirection: number): Promise<APIKeyPage> {
|
||||
const u = new URL(`${this.ROOT_PATH}/apikeys/${projectID}`);
|
||||
const u = new URL(`${this.ROOT_PATH}/apikeys/${projectID}`, window.location.href);
|
||||
u.searchParams.set('search', search);
|
||||
u.searchParams.set('limit', limit);
|
||||
u.searchParams.set('page', page);
|
||||
|
Loading…
Reference in New Issue
Block a user