From a70cd368af3f90c12ad3d0dfb35ab75b98d5e619 Mon Sep 17 00:00:00 2001 From: eleith Date: Mon, 29 Jul 2024 14:38:47 -0700 Subject: [PATCH] fix(server): use fqdn for og:image meta tag value (#11082) * attempt to use fqdn for og:image opengraph image specifies that the url contains http or https, thus implying a fqdn. this change uses the external domain from the server config to attempt to make the og:image have both the existing path to the thumbnail along with the desired domain if the server setting is empty, the old behavior will persist please note, some og implementations do work with relative paths, so not all og image checkers may still pass, but not all implementations have this fallback and thus will not find the image otherwise * tests and ssr for og:image value as fqdn * formatting * fix test * formatting * formatting * fix tests getConfig was requiring authentication. using already initiated global stores instead * load config in shared link service itself * join host and pathname/params safely * use origin instead of host for full domain string also fixes lint and address the imageURL type which is optional * chore: clean up --------- Co-authored-by: eleith Co-authored-by: eleith Co-authored-by: Jason Rasmussen --- e2e/src/api/specs/shared-link.e2e-spec.ts | 7 +++++++ server/src/services/shared-link.service.spec.ts | 14 +++++++++++--- server/src/services/shared-link.service.ts | 17 ++++++++++++++--- .../[[photos=photos]]/[[assetId=id]]/+page.ts | 12 ++++++------ web/src/routes/+layout.svelte | 16 +++++++++++++--- 5 files changed, 51 insertions(+), 15 deletions(-) diff --git a/e2e/src/api/specs/shared-link.e2e-spec.ts b/e2e/src/api/specs/shared-link.e2e-spec.ts index 3448b2c5f2..e62d18b72d 100644 --- a/e2e/src/api/specs/shared-link.e2e-spec.ts +++ b/e2e/src/api/specs/shared-link.e2e-spec.ts @@ -112,6 +112,13 @@ describe('/shared-links', () => { expect(resp.header['content-type']).toContain('text/html'); expect(resp.text).toContain(``); }); + + it('should have fqdn og:image meta tag for shared asset', async () => { + const resp = await request(shareUrl).get(`/${linkWithAssets.key}`); + expect(resp.status).toBe(200); + expect(resp.header['content-type']).toContain('text/html'); + expect(resp.text).toContain(` - + {#if $page.data.meta.imageUrl} + + {/if} - + {#if $page.data.meta.imageUrl} + + {/if} {/if}