Record your screen, ship a demo. Free and open-source, GPU-accelerated, no watermarks, no subscriptions. Windows, macOS, Linux. Actively maintained.
TypeScript cross-platformelectronffmpegopen-sourceproduct-demorustscreen-capturescreen-recorderscreen-recordingscreen-studioscreencastspeech-to-texttypescriptvideo-editingvideo-editorwaylandwgpuwhisper
fix(website): count only OpenScreen release assets on github.com as downloads
EtienneLescot1efc836b78fe
diff --git a/website/src/lib/download-target.test.ts b/website/src/lib/download-target.test.tsindex b2c4f28c1..e940ac28c 100644--- a/website/src/lib/download-target.test.ts+++ b/website/src/lib/download-target.test.ts@@ -163,4 +163,6 @@ test("a download click names the asset kind and the release, and other links areassert.equal(downloadClick(STORE_INSTALLER_URL)?.kind, "store");assert.equal(downloadClick("https://github.com/getopenscreen/openscreen/releases/latest"), null);assert.equal(downloadClick(STORE_URL), null);+ assert.equal(downloadClick("https://github.com/someone/else/releases/download/v1/x.dmg"), null);+ assert.equal(downloadClick(`https://example.com/?next=${base}/Openscreen-mac-arm64.dmg`), null);});diff --git a/website/src/lib/download-target.ts b/website/src/lib/download-target.tsindex 461e0769b..5518c8aaf 100644--- a/website/src/lib/download-target.ts+++ b/website/src/lib/download-target.ts@@ -117,10 +117,19 @@ export type DownloadClick = {file: string | null;};-/** What a link downloads, for the analytics event, or null when it downloads nothing. */+const RELEASE_ASSET_PATH = /^\/getopenscreen\/openscreen\/releases\/download\/([^/]+)\/([^/]+)$/;++/** What a link downloads, for the analytics event, or null when it downloads nothing: an+ * OpenScreen release asset on github.com, or the Store installer. */export function downloadClick(href: string): DownloadClick | null {if (href.startsWith(STORE_INSTALLER_URL)) return { kind: "store", version: null, file: null };- const match = /\/releases\/download\/([^/]+)\/([^/?#]+)/.exec(href);+ let url: URL;+ try {+ url = new URL(href);+ } catch {+ return null;+ }+ const match = url.hostname === "github.com" ? RELEASE_ASSET_PATH.exec(url.pathname) : null;if (!match) return null;const file = decodeURIComponent(match[2]);const kind = (Object.keys(ASSET_PATTERNS) as AssetKind[]).find((k) =>