fix: Self-hosted grist embeds not matching

closes #6451
This commit is contained in:
Tom Moor
2024-02-10 15:58:40 -05:00
parent 012d8c2ae7
commit 2d6a7ed244
2 changed files with 15 additions and 4 deletions

View File

@@ -93,7 +93,9 @@ export class EmbedDescriptor {
matcher(url: string): false | RegExpMatchArray {
const regexes = this.regexMatch ?? [];
const settingsDomainRegex = urlRegex(this.settings?.url);
const settingsDomainRegex = this.settings?.url
? urlRegex(this.settings?.url)
: undefined;
if (settingsDomainRegex) {
regexes.unshift(settingsDomainRegex);
@@ -372,11 +374,13 @@ const embeds: EmbedDescriptor[] = [
keywords: "spreadsheet",
regexMatch: [new RegExp("^https?://([a-z.-]+\\.)?getgrist\\.com/(.+)$")],
transformMatch: (matches: RegExpMatchArray) => {
if (matches[0].includes("style=singlePage")) {
return matches[0];
const input = matches.input ?? matches[0];
if (input.includes("style=singlePage")) {
return input;
}
return matches[0].replace(/(\?embed=true)?$/, "?embed=true");
return input.replace(/(\?embed=true)?$/, "?embed=true");
},
icon: <Img src="/images/grist.png" alt="Grist" />,
}),