Turn any website into a lightweight desktop app with one command, on macOS, Windows and Linux.
Rust chatgptclaudeclidesktopdesktop-appelectron-alternativegeminilinuxmacosnativefierno-electronrusttauriweb-to-desktopwebsite-to-appwebviewwindowsyoutube
refactor(inject): drop the image filename branch the old context menu used
Tw932100f8a0135f
diff --git a/docs/advanced-usage.md b/docs/advanced-usage.mdindex 6253a96b..07fd5046 100644--- a/docs/advanced-usage.md+++ b/docs/advanced-usage.md@@ -48,7 +48,7 @@ document.addEventListener("keydown", (e) => {Downloads also report in the window itself: a short message at the bottom right says when a download starts, when it is saved to the download folder, when it fails, and when the download folder cannot be used, then fades after about three seconds. The language follows the system, Chinese or English. Downloads that end on a non-2xx response are reported as failed, not saved.-When a download fails, Pake shows a notification in Chinese or English based on the browser language. It covers regular HTTP(S), Data URI (base64 encoded files), Blob URL (dynamically generated files) and context menu downloads, uses native OS notifications once permission is granted, and falls back to console logging otherwise. To enable notifications, request permission in your injected JavaScript:+When a download fails, Pake shows a notification in Chinese or English based on the browser language. It covers regular HTTP(S), Data URI (base64 encoded files), and Blob URL (dynamically generated files) downloads, uses native OS notifications once permission is granted, and falls back to console logging otherwise. To enable notifications, request permission in your injected JavaScript:```javascript// Request notification permission on app startdiff --git a/docs/advanced-usage_CN.md b/docs/advanced-usage_CN.mdindex 259f3261..f25f0a19 100644--- a/docs/advanced-usage_CN.md+++ b/docs/advanced-usage_CN.md@@ -48,7 +48,7 @@ document.addEventListener("keydown", (e) => {下载状态也会直接显示在窗口里,右下角会弹出一条短提示,告诉你开始下载、已保存到下载目录、下载失败或者下载目录无法使用,大约三秒后淡出,语言跟着系统走,中文或英文。服务器返回非 2xx 状态的下载会提示失败,不会当成成功保存。-下载失败时 Pake 会弹出通知,语言自动匹配系统与浏览器(中文或英文),覆盖常规 HTTP(S)、Data URI(base64 编码文件)、Blob URL(动态生成的文件)和右键菜单发起的下载,授予通知权限后使用原生系统通知,没有权限时降级到控制台日志。要启用通知,在注入的 JavaScript 中请求权限:+下载失败时 Pake 会弹出通知,语言自动匹配系统与浏览器(中文或英文),覆盖常规 HTTP(S)、Data URI(base64 编码文件)和 Blob URL(动态生成的文件)下载,授予通知权限后使用原生系统通知,没有权限时降级到控制台日志。要启用通知,在注入的 JavaScript 中请求权限:```javascript// 在应用启动时请求通知权限diff --git a/src-tauri/src/inject/event.js b/src-tauri/src/inject/event.jsindex 4f3674df..5b4aa766 100644--- a/src-tauri/src/inject/event.js+++ b/src-tauri/src/inject/event.js@@ -1647,9 +1647,8 @@ function decodeFilenameSegment(segment) {}}-function getFilenameFromUrl(url, options = {}) {+function getFilenameFromUrl(url) {const timestamp = new Date().toISOString().replace(/[:.]/g, "-");- const isImage = options?.isImage === true;if (typeof url === "string" && url.startsWith("data:")) {// Read only the MIME type: stop at ';' (params) or ',' (data), whichever@@ -1691,27 +1690,10 @@ function getFilenameFromUrl(url, options = {}) {return segment;}- if (isImage) {- const lower = url.toLowerCase();- if (/\.(jpe?g)(?:$|[?#&])|[?&]format=jpe?g\b/.test(lower)) {- return `image-${timestamp}.jpg`;- }- if (/\.gif(?:$|[?#&])|[?&]format=gif\b/.test(lower)) {- return `image-${timestamp}.gif`;- }- if (/\.webp(?:$|[?#&])|[?&]format=webp\b/.test(lower)) {- return `image-${timestamp}.webp`;- }- if (/\.svg(?:$|[?#&])|[?&]format=svg\b/.test(lower)) {- return `image-${timestamp}.svg`;- }- return `image-${timestamp}.png`;- }-// Leave extensionless link downloads without a fake .png suffix so the// Rust download handler can apply Content-Disposition or Content-Type.return segment || `download-${timestamp}`;} catch (e) {- return isImage ? `image-${timestamp}.png` : `download-${timestamp}`;+ return `download-${timestamp}`;}}diff --git a/tests/unit/event-link-guard.test.js b/tests/unit/event-link-guard.test.jsindex 77307052..db126bcb 100644--- a/tests/unit/event-link-guard.test.js+++ b/tests/unit/event-link-guard.test.js@@ -1576,21 +1576,8 @@ describe("extensionless download filenames and native context menu", () => {expect(rootFallback).not.toMatch(/\.png$/);});- it("uses image-* extensions only when explicitly requested for images", () => {+ it("maps a non-image data URI subtype to its extension", () => {const context = loadEventHelpers();- expect(- context.getFilenameFromUrl(- "https://cdn.example.com/media/123?format=webp",- {- isImage: true,- },- ),- ).toMatch(/^image-.*\.webp$/);- expect(- context.getFilenameFromUrl("https://cdn.example.com/media/123", {- isImage: true,- }),- ).toMatch(/^image-.*\.png$/);expect(context.getFilenameFromUrl("data:text/csv;base64,YSwx")).toMatch(/^download-.*\.csv$/,);