Skip to content

Commit

Permalink
Embeds only start with /projects or /documents
Browse files Browse the repository at this point in the history
  • Loading branch information
eyeseast committed Jan 17, 2025
1 parent 6bce5fa commit 00fd8e0
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/lib/utils/embed.ts
Original file line number Diff line number Diff line change
Expand Up @@ -287,6 +287,7 @@ export const settingsConfig: Record<keyof EmbedSettings, EmbedSettingConfig> = {
* @param url
*/
export function isEmbed(url: URL): Boolean {
if (!url.pathname.match(/^\/(documents|projects)/)) return false;
return (
url.searchParams.has("embed") || url.hostname === "embed.documentcloud.org"
);
Expand Down
4 changes: 4 additions & 0 deletions src/lib/utils/tests/embed.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,10 @@ describe("embed utilities", () => {
"https://www.documentcloud.org/documents/2622-agreement-between-conservatives-and-liberal-democrats-to-form-a-coalition-government/?embed",
true,
],
[
"https://embed.documentcloud.org/_app/immutable/chunks/navigation.CziXxwWJ.js",
false,
],
];

for (const [url, embed] of urls) {
Expand Down

0 comments on commit 00fd8e0

Please sign in to comment.