(core) Add org to FormAPI URL paths

Summary:
In some environments, URLs produced by FormAPI were missing an org, making them
ambiguous. This ensures that an org is always included in the path.

Test Plan: Manual.

Reviewers: paulfitz

Reviewed By: paulfitz

Subscribers: paulfitz

Differential Revision: https://phab.getgrist.com/D4200
This commit is contained in:
George Gevoian 2024-02-22 12:01:17 -05:00
parent c6fd79ac1f
commit 219b1f3f87

View File

@ -1,5 +1,6 @@
import {BaseAPI, IOptions} from 'app/common/BaseAPI'; import {BaseAPI, IOptions} from 'app/common/BaseAPI';
import {CellValue, ColValues} from 'app/common/DocActions'; import {CellValue, ColValues} from 'app/common/DocActions';
import {addCurrentOrgToPath} from 'app/common/urlUtils';
/** /**
* Form and associated field metadata from a Grist view section. * Form and associated field metadata from a Grist view section.
@ -82,11 +83,8 @@ interface CreateRecordWithShareKeyOptions extends CreateRecordCommonOptions {
type CreateRecordOptions = CreateRecordWithDocIdOptions | CreateRecordWithShareKeyOptions; type CreateRecordOptions = CreateRecordWithDocIdOptions | CreateRecordWithShareKeyOptions;
export class FormAPIImpl extends BaseAPI implements FormAPI { export class FormAPIImpl extends BaseAPI implements FormAPI {
private _url: string; constructor(private _homeUrl: string, options: IOptions = {}) {
constructor(url: string, options: IOptions = {}) {
super(options); super(options);
this._url = url.replace(/\/$/, '');
} }
public async getForm(options: GetFormOptions): Promise<Form> { public async getForm(options: GetFormOptions): Promise<Form> {
@ -114,4 +112,8 @@ export class FormAPIImpl extends BaseAPI implements FormAPI {
}); });
} }
} }
private get _url(): string {
return addCurrentOrgToPath(this._homeUrl);
}
} }