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
feat: support a custom app download directory
youxi7982b3a690b29b9
diff --git a/AGENTS.md b/AGENTS.mdindex baecad30..88b67fb0 100644--- a/AGENTS.md+++ b/AGENTS.md@@ -105,6 +105,7 @@ Proactive latent-bug sweeps use `.agents/skills/bugs/SKILL.md`. Pick one row and- macOS auth-popup behavior is fragile. Auth and sign-in URLs that trigger WebKit's native auth-popup path should stay in the current window when that path can abort the app. URL matching lives in `src-tauri/src/inject/auth.js` (`matchesAuthUrl`, injected from `src-tauri/src/app/window.rs`) and is covered by `tests/unit/auth-sso-patterns.test.js`; main-page `window.open` interception lives in `event.js`, and the lightweight subframe interception lives in `frame_links.js`. Changes need the corresponding routing tests. Apple Sign-In (`appleid.apple.com` / `AppleAuthentication` named windows) is the exception and must keep the native `window.open` popup.- Auth routing matches provider hostnames and endpoint-shaped paths separately, never query strings or fragments. Tracking links carrying a login URL must still open externally. Cover main-page and subframe clicks in `tests/browser/popup-routing.mjs`; classifier-only tests do not prove routing.- Blank/two-stage popups need a real WindowProxy, not the main window. Normalize omitted/empty URLs to `about:blank` in both JS entry points: Tauri rejects WebKit's empty URL before calling `on_new_window`. The default native handler must create a managed blank popup with Pake's download delegate even without `--new-window`; `NewWindowResponse::Allow` does not provide that delegate. Verify actual macOS attachment bytes and preservation of the main URL, not only Chromium popup creation.+- `--download-dir` / `downloadDir` is embedded as trusted `pake.download_dir`, shared by native and IPC downloads through `get_download_dir`. Empty means system Downloads; quoted `~/path` expands against the runtime user home. Reject relative paths and absolute tilde suffixes, create missing directories on download, and fail without redirecting to another folder when resolution fails. Do not accept a directory from remote-page IPC arguments.- Do not open a synchronous native save dialog inside `on_download(Requested)`. Wry 0.54.2 holds a `RefCell` mutable borrow across that callback; a modal panel allows another download callback to reenter and panic. A native two-download probe reproduced this with 100 ms and 500 ms spacing. The macOS completion event also omits the destination path, so URL-only bookkeeping cannot safely identify concurrent downloads of the same URL.- WebKit subframes need `initialization_script_for_all_frames` for the lightweight config/auth/link bridge. Keep page UI and clipboard injection separate. `link_policy.js` owns internal URL matching for the main page and `frame_links.js`; the receiver must recheck descendant source, protocol, internal/auth classification, and force policy before calling the external opener. Never route frame messages through top-level internal navigation: sandboxed content can forge them. Preserve native blank/two-stage, named-frame, auth, and download behavior; known external iframe links are the repaired surface. Cover pre-DOMContentLoaded messages and discard queued messages when the document leaves.- Find's DOM-mark fallback must not observe its own highlighter mutations. Pause observation while rescanning/updating marks, then resume only while Find is open; real page edits must still refresh results. A mock without MutationObserver cannot prove this path. Icon download deadlines likewise cover response bodies, not just response headers.diff --git a/bin/cli.ts b/bin/cli.tsindex ffefa37d..8edd68b2 100644--- a/bin/cli.ts+++ b/bin/cli.ts@@ -13,7 +13,7 @@ import {throwIfBuildCancelled,} from './utils/build-workspace';import { isPakeError, PakeError } from './utils/error';-import { validateUrlInput } from './utils/validate';+import { validateUrlInput, validateDownloadDirInput } from './utils/validate';import {ERROR_EXIT_CODES,PakeErrorCode,@@ -127,6 +127,8 @@ program.action(async (urlArg: string, options: PakeCliOptions) => {}}+ validateDownloadDirInput(options.downloadDir);+if (!url) {if (jsonMode) {throw new PakeError('No URL or local path to package.', {diff --git a/bin/defaults.ts b/bin/defaults.tsindex 2d864b12..4b484e53 100644--- a/bin/defaults.ts+++ b/bin/defaults.ts@@ -33,6 +33,7 @@ export const DEFAULT_PAKE_OPTIONS: PakeCliOptions = {useLocalFile: false,systemTrayIcon: '',proxyUrl: '',+ downloadDir: '',basicAuth: false,debug: false,json: false,diff --git a/bin/helpers/cli-program.ts b/bin/helpers/cli-program.tsindex ea367f7f..76fefc2c 100644--- a/bin/helpers/cli-program.ts+++ b/bin/helpers/cli-program.ts@@ -69,6 +69,11 @@ ${green('|_| \\__,_|_|\\_\\___| can turn any webpage into a desktop app with},DEFAULT.inject,)+ .option(+ '--download-dir <path>',+ 'App download directory (absolute path or ~/path; default: system Downloads)',+ DEFAULT.downloadDir,+ ).option('--debug', 'Debug build and more output', DEFAULT.debug).option('--json',diff --git a/bin/helpers/merge.ts b/bin/helpers/merge.tsindex 7d02fdd4..d8c45d6d 100644--- a/bin/helpers/merge.ts+++ b/bin/helpers/merge.ts@@ -482,6 +482,7 @@ async function injectCustomCode(}tauriConf.pake.proxy_url = proxyUrl || '';+ tauriConf.pake.download_dir = options.downloadDir || '';tauriConf.pake.basic_auth = basicAuth;tauriConf.pake.multi_instance = multiInstance;tauriConf.pake.multi_window = multiWindow;diff --git a/bin/types.ts b/bin/types.tsindex a8c29dcd..d1770ecb 100644--- a/bin/types.ts+++ b/bin/types.ts@@ -81,6 +81,9 @@ export interface PakeCliOptions {/** External scripts that need to be injected into the page. */inject: string[];+ // Download directory in the packaged app; empty uses the system default.+ downloadDir: string;+// Set Api ProxyproxyUrl: string;@@ -204,6 +207,7 @@ export interface PakeConfig {system_tray: PlatformSpecific<boolean>;system_tray_path: string;proxy_url: string;+ download_dir: string;basic_auth: boolean;multi_instance: boolean;multi_window: boolean;diff --git a/bin/utils/validate.ts b/bin/utils/validate.tsindex df769119..8dfae527 100644--- a/bin/utils/validate.ts+++ b/bin/utils/validate.ts@@ -1,4 +1,6 @@import fs from 'fs';+import path from 'path';+import { PakeError } from './error';import { InvalidArgumentError } from 'commander';import { normalizeUrl } from './url';@@ -42,3 +44,28 @@ export function validateUrlInput(url: string) {return url;}++export function validateDownloadDirInput(value: string): string {+ if (value === '') return value;+ const homeRelative = value.startsWith('~/') ? value.slice(2) : null;+ const invalidHomePath =+ homeRelative !== null &&+ (path.isAbsolute(homeRelative) ||+ (process.platform === 'win32' &&+ /^(?:[a-zA-Z]:|[\\/])/.test(homeRelative)));+ if (+ invalidHomePath ||+ value.includes('\0') ||+ !(path.isAbsolute(value) || value === '~' || value.startsWith('~/')) ||+ (process.platform === 'win32' &&+ value !== '~' &&+ !value.startsWith('~/') &&+ !/^(?:[a-zA-Z]:[\\/]|[\\/]{2}[^\\/]+[\\/][^\\/]+)/.test(value))+ ) {+ throw new PakeError('Invalid download directory.', {+ code: 'INVALID_INPUT',+ hint: 'Use an absolute path or a quoted ~/path; relative paths are not supported.',+ });+ }+ return value;+}diff --git a/dist/cli.js b/dist/cli.jsindex 4fa65bf0..3e2eef85 100644--- a/dist/cli.js+++ b/dist/cli.js@@ -1211,6 +1211,7 @@ async function injectCustomCode(options, tauriConf) {await fsExtra.writeFile(injectFilePath, '');}tauriConf.pake.proxy_url = proxyUrl || '';+ tauriConf.pake.download_dir = options.downloadDir || '';tauriConf.pake.basic_auth = basicAuth;tauriConf.pake.multi_instance = multiInstance;tauriConf.pake.multi_window = multiWindow;@@ -3368,6 +3369,7 @@ const DEFAULT_PAKE_OPTIONS = {useLocalFile: false,systemTrayIcon: '',proxyUrl: '',+ downloadDir: '',basicAuth: false,debug: false,json: false,@@ -3432,6 +3434,28 @@ function validateUrlInput(url) {}return url;}+function validateDownloadDirInput(value) {+ if (value === '')+ return value;+ const homeRelative = value.startsWith('~/') ? value.slice(2) : null;+ const invalidHomePath = homeRelative !== null &&+ (path.isAbsolute(homeRelative) ||+ (process.platform === 'win32' &&+ /^(?:[a-zA-Z]:|[\\/])/.test(homeRelative)));+ if (invalidHomePath ||+ value.includes('\0') ||+ !(path.isAbsolute(value) || value === '~' || value.startsWith('~/')) ||+ (process.platform === 'win32' &&+ value !== '~' &&+ !value.startsWith('~/') &&+ !/^(?:[a-zA-Z]:[\\/]|[\\/]{2}[^\\/]+[\\/][^\\/]+)/.test(value))) {+ throw new PakeError('Invalid download directory.', {+ code: 'INVALID_INPUT',+ hint: 'Use an absolute path or a quoted ~/path; relative paths are not supported.',+ });+ }+ return value;+}function getCliProgram() {const { green, yellow } = chalk;@@ -3468,6 +3492,7 @@ ${green('|_| \\__,_|_|\\_\\___| can turn any webpage into a desktop app with// If previous values exist (from multiple --inject options), merge themreturn previous ? [...previous, ...files] : files;}, DEFAULT_PAKE_OPTIONS.inject)+ .option('--download-dir <path>', 'App download directory (absolute path or ~/path; default: system Downloads)', DEFAULT_PAKE_OPTIONS.downloadDir).option('--debug', 'Debug build and more output', DEFAULT_PAKE_OPTIONS.debug).option('--json', 'Machine-readable output: logs to stderr, one JSON result on stdout', DEFAULT_PAKE_OPTIONS.json).option('--config <path>', 'Load options from a JSON config file (fields mirror CLI options, see schema/pake.schema.json)')@@ -3802,6 +3827,7 @@ program.action(async (urlArg, options) => {}}}+ validateDownloadDirInput(options.downloadDir);if (!url) {if (jsonMode) {throw new PakeError('No URL or local path to package.', {diff --git a/docs/cli-usage.md b/docs/cli-usage.mdindex 68162a3f..c397c94c 100644--- a/docs/cli-usage.md+++ b/docs/cli-usage.md@@ -588,6 +588,16 @@ Supports both comma-separated and multiple option formats:--inject ./tools/style.css```+#### [download-dir]++Choose where the packaged app saves downloads. Both regular link downloads and native browser downloads use this directory; the default is the system Downloads folder.++```bash+pake https://example.com --name MyApp --download-dir '~/Documents/MyApp'+```++Use an absolute path (such as `C:\Users\Alice\Documents\MyApp` on Windows) or a quoted `~/path`. Quoting preserves `~` so it resolves to the app user's home when the app runs, rather than the build machine's home. Missing directories are created on the first download. Relative paths are rejected; an inaccessible directory causes the download to fail without silently saving elsewhere. The equivalent JSON config field is `downloadDir`. Rebuild an existing app to change its download directory.+#### [proxy-url]Set proxy server for all network requests. Supports HTTP, HTTPS, and SOCKS5. Available on Windows and Linux. On macOS, requires macOS 14+.diff --git a/docs/cli-usage_CN.md b/docs/cli-usage_CN.mdindex 8b7e714d..b782fe57 100644--- a/docs/cli-usage_CN.md+++ b/docs/cli-usage_CN.md@@ -586,6 +586,16 @@ pake ./my-app/index.html --name "my-app" --use-local-file--inject ./tools/style.css```+#### [download-dir]++指定打包后应用的下载目录,普通链接下载和浏览器原生下载均使用该目录,默认仍为系统 Downloads 文件夹。++```bash+pake https://example.com --name MyApp --download-dir '~/Documents/MyApp'+```++支持绝对路径(如 Windows 的 `C:\Users\Alice\Documents\MyApp`)或带引号的 `~/路径`,引号可保留 `~`,让它在应用运行时指向使用者的主目录,而非打包机器的主目录。目录不存在时会在首次下载时创建;不支持相对路径,目录不可访问时下载会失败,不会悄悄改存到其他位置。JSON 配置对应字段为 `downloadDir`,修改已有应用的下载目录需要重新打包。+#### [proxy-url]为所有网络请求设置代理服务器。支持 HTTP、HTTPS 和 SOCKS5。在 Windows 和 Linux 上可用。在 macOS 上需要 macOS 14+。diff --git a/schema/pake.schema.json b/schema/pake.schema.jsonindex 8da9def9..ff50c0e8 100644--- a/schema/pake.schema.json+++ b/schema/pake.schema.json@@ -81,6 +81,11 @@"description": "Debug build with more output.","default": false},+ "downloadDir": {+ "type": "string",+ "description": "App download directory: an absolute path or ~/path resolved against the app user's home at runtime. Empty uses system Downloads. Created on first download if missing.",+ "default": ""+ },"proxyUrl": {"type": "string","description": "Proxy URL for all network requests (http://, https://, socks5://).",diff --git a/src-tauri/pake.json b/src-tauri/pake.jsonindex 75a4e3c9..28568487 100644--- a/src-tauri/pake.json+++ b/src-tauri/pake.json@@ -38,6 +38,7 @@"system_tray_path": "icons/icon.png","inject": [],"proxy_url": "",+ "download_dir": "","multi_instance": false,"multi_window": false}diff --git a/src-tauri/src/app/config.rs b/src-tauri/src/app/config.rsindex d99e11c9..b82b6db0 100644--- a/src-tauri/src/app/config.rs+++ b/src-tauri/src/app/config.rs@@ -83,6 +83,8 @@ pub struct PakeConfig {pub system_tray: FunctionON,pub system_tray_path: String,pub proxy_url: String,+ #[serde(default)]+ pub download_dir: String,/// Prompt for HTTP Basic credentials at runtime on macOS. WKWebView does/// not provide its own 401 login dialog, while Windows and Linux WebViews/// handle this flow natively.diff --git a/src-tauri/src/app/invoke.rs b/src-tauri/src/app/invoke.rsindex 20528508..8c20a847 100644--- a/src-tauri/src/app/invoke.rs+++ b/src-tauri/src/app/invoke.rs@@ -1,7 +1,7 @@use crate::app::navigation::{history_step, reload_window};use crate::util::{- check_file_or_append, get_download_message_with_lang, sanitize_download_filename, show_toast,- MessageType,+ check_file_or_append, get_download_dir, get_download_message_with_lang,+ sanitize_download_filename, show_toast, MessageType,};use std::fs::File;use std::io::Write;@@ -113,10 +113,13 @@ pub async fn download_file(&get_download_message_with_lang(MessageType::Start, params.language.clone()),);- let download_dir = app- .path()- .download_dir()- .map_err(|e| format!("Failed to get download dir: {}", e))?;+ let download_dir = get_download_dir(&app).map_err(|error| {+ show_toast(+ &window,+ &get_download_message_with_lang(MessageType::DirectoryFailure, params.language.clone()),+ );+ error+ })?;let output_path = download_dir.join(sanitize_download_filename(¶ms.filename));diff --git a/src-tauri/src/app/window.rs b/src-tauri/src/app/window.rsindex b5ee832e..ded97abc 100644--- a/src-tauri/src/app/window.rs+++ b/src-tauri/src/app/window.rs@@ -1,7 +1,7 @@use crate::app::config::PakeConfig;use crate::util::{- check_file_or_append, get_data_dir, get_download_message_with_lang, sanitize_download_filename,- show_toast, MessageType,+ check_file_or_append, get_data_dir, get_download_dir, get_download_message_with_lang,+ sanitize_download_filename, show_toast, MessageType,};#[cfg(target_os = "macos")]use dispatch::Queue;@@ -690,7 +690,7 @@ fn build_window(}// Capture webview-initiated downloads (blob:, data:, Content-Disposition,- // etc.) and write them to the OS Downloads folder. This is essential for+ // etc.) and write them to the configured download folder. This is essential for// sites with a strict Content-Security-Policy (e.g. Gemini): their// `connect-src` blocks Tauri's IPC origin, so downloads cannot be routed// through the JS bridge, and downloads triggered from a sandboxed iframe@@ -700,7 +700,7 @@ fn build_window(let download_handle = app.clone();window_builder = window_builder.on_download(move |webview, event| match event {DownloadEvent::Requested { url, destination } => {- match download_handle.path().download_dir() {+ match get_download_dir(&download_handle) {Ok(download_dir) => {let filename = destination.file_name()@@ -717,10 +717,23 @@ fn build_window(let target = download_dir.join(sanitize_download_filename(&filename));if let Some(path_str) = target.to_str() {*destination = PathBuf::from(check_file_or_append(path_str));+ } else {+ eprintln!("[Pake] Download destination is not valid UTF-8");+ return false;}}Err(error) => {eprintln!("[Pake] Failed to resolve download dir: {error}");+ if let Some(window) = download_handle.get_webview_window(webview.label()) {+ show_toast(+ &window,+ &get_download_message_with_lang(+ MessageType::DirectoryFailure,+ None,+ ),+ );+ }+ return false;}}truediff --git a/src-tauri/src/util.rs b/src-tauri/src/util.rsindex b3c36ee2..fa6facb9 100644--- a/src-tauri/src/util.rs+++ b/src-tauri/src/util.rs@@ -1,4 +1,5 @@use crate::app::config::PakeConfig;+use crate::app::window::MultiWindowState;use std::env;use std::path::{Path, PathBuf};use tauri::{AppHandle, Config, Manager, WebviewWindow};@@ -47,6 +48,55 @@ pub fn get_data_dir(app: &AppHandle, package_name: String) -> std::io::Result<PaOk(data_dir)}+/// Both native and IPC downloads use the trusted, packaged configuration.+pub fn get_download_dir(app: &AppHandle) -> Result<PathBuf, String> {+ let state = app+ .try_state::<MultiWindowState>()+ .ok_or("Missing app download configuration")?;+ let configured = &state.pake_config.download_dir;+ let directory = if configured.is_empty() {+ app.path().download_dir().map_err(|e| e.to_string())?+ } else {+ let home = if configured == "~" || configured.starts_with("~/") {+ Some(app.path().home_dir().map_err(|e| e.to_string())?)+ } else {+ None+ };+ expand_download_dir(configured, home.as_deref())?+ };+ std::fs::create_dir_all(&directory).map_err(|e| {+ format!(+ "Cannot create download directory {}: {e}",+ directory.display()+ )+ })?;+ Ok(directory)+}++fn expand_download_dir(configured: &str, home: Option<&Path>) -> Result<PathBuf, String> {+ let directory = if configured == "~" || configured.starts_with("~/") {+ let home = home.ok_or("Cannot resolve the app user's home directory")?;+ let relative = Path::new(configured.strip_prefix("~/").unwrap_or(""));+ if relative.has_root()+ || matches!(+ relative.components().next(),+ Some(std::path::Component::Prefix(_))+ )+ {+ return Err(+ "Download directory after ~/ must be relative to the home directory".into(),+ );+ }+ home.join(relative)+ } else {+ PathBuf::from(configured)+ };+ if !directory.is_absolute() || configured.contains('\0') {+ return Err("Download directory must be an absolute path or ~/path".into());+ }+ Ok(directory)+}+pub fn show_toast(window: &WebviewWindow, message: &str) {let script = format!(r#"pakeToast("{message}");"#);if let Err(error) = window.eval(&script) {@@ -58,6 +108,7 @@ pub enum MessageType {Start,Success,Failure,+ DirectoryFailure,}pub fn get_download_message_with_lang(@@ -70,8 +121,8 @@ pub fn get_download_message_with_lang(let default_success_message = "Download successful, saved to download directory~";let chinese_success_message = "下载成功,已保存到下载目录~";- let default_failure_message = "Download failed, please check your network connection~";- let chinese_failure_message = "下载失败,请检查你的网络连接~";+ let default_failure_message = "Download failed~";+ let chinese_failure_message = "下载失败~";let is_chinese = language.as_ref()@@ -100,12 +151,14 @@ pub fn get_download_message_with_lang(MessageType::Start => chinese_start_message,MessageType::Success => chinese_success_message,MessageType::Failure => chinese_failure_message,+ MessageType::DirectoryFailure => "无法保存到下载目录~",}} else {match message_type {MessageType::Start => default_start_message,MessageType::Success => default_success_message,MessageType::Failure => default_failure_message,+ MessageType::DirectoryFailure => "Cannot save to the download directory~",}}.to_string()@@ -204,6 +257,57 @@ mod tests {dir}+ #[test]+ fn expand_download_dir_preserves_absolute_paths_without_home() {+ let absolute = temp_path("My Downloads");+ assert_eq!(+ expand_download_dir(absolute.to_str().unwrap(), None).unwrap(),+ absolute+ );+ fs::remove_dir_all(absolute.parent().unwrap()).unwrap();+ }++ #[test]+ fn expand_download_dir_uses_runtime_home() {+ let home = temp_path("home");+ assert_eq!(+ expand_download_dir("~/Documents/My App", Some(&home)).unwrap(),+ home.join("Documents/My App")+ );+ assert_eq!(expand_download_dir("~", Some(&home)).unwrap(), home);+ assert!(expand_download_dir("~/Downloads", None).is_err());+ fs::remove_dir_all(home.parent().unwrap()).unwrap();+ }++ #[test]+ fn expand_download_dir_rejects_home_replacement() {+ let home = temp_path("home");+ assert!(expand_download_dir("~//tmp", Some(&home)).is_err());+ #[cfg(target_os = "windows")]+ for value in ["~/C:\\other", "~/C:other", "~/\\other"] {+ assert!(+ expand_download_dir(value, Some(&home)).is_err(),+ "accepted {value}"+ );+ }+ fs::remove_dir_all(home.parent().unwrap()).unwrap();+ }++ #[test]+ fn expand_download_dir_rejects_relative_and_nul_paths() {+ for value in [+ "downloads",+ "./downloads",+ "~alice/downloads",+ "~/bad\0path",+ ] {+ assert!(+ expand_download_dir(value, None).is_err(),+ "accepted {value}"+ );+ }+ }+#[test]fn check_file_or_append_returns_input_when_missing() {let path = temp_path("ghost.txt");diff --git a/tests/unit/config-file.test.ts b/tests/unit/config-file.test.tsindex 81b34caa..d3326a54 100644--- a/tests/unit/config-file.test.ts+++ b/tests/unit/config-file.test.ts@@ -94,6 +94,12 @@ describe('loadConfigFile', () => {});});+ it('accepts a runtime download directory without resolving the build user home', async () => {+ const configPath = await writeConfig({ downloadDir: '~/Documents/My App' });+ const loaded = await loadConfigFile(configPath, validKeys);+ expect(loaded.options.downloadDir).toBe('~/Documents/My App');+ });+it('rejects a missing file with INVALID_INPUT', async () => {const missing = path.join(tmpDir, 'nope.json');await expect(loadConfigFile(missing, validKeys)).rejects.toMatchObject({diff --git a/tests/unit/validate-url-input.test.ts b/tests/unit/validate-url-input.test.tsindex 9778755d..8c8d44b0 100644--- a/tests/unit/validate-url-input.test.ts+++ b/tests/unit/validate-url-input.test.ts@@ -1,6 +1,6 @@import { describe, expect, it } from 'vitest';import { InvalidArgumentError } from 'commander';-import { validateUrlInput } from '@/utils/validate';+import { validateUrlInput, validateDownloadDirInput } from '@/utils/validate';describe('validateUrlInput', () => {it('prepends https:// to a bare domain', () => {@@ -43,3 +43,44 @@ describe('validateUrlInput', () => {expect(validateUrlInput('example.com')).toBe('https://example.com');});});++describe('validateDownloadDirInput', () => {+ it('keeps defaults, absolute paths, and runtime home paths unchanged', () => {+ for (const value of ['', process.cwd(), '~', '~/Documents/My App']) {+ expect(validateDownloadDirInput(value)).toBe(value);+ }+ });++ it('rejects relative, user-specific tilde, and NUL paths', () => {+ for (const value of [+ 'downloads',+ './downloads',+ '~alice/downloads',+ ' ',+ '~/bad\0path',+ '~//tmp',+ ]) {+ expect(() => validateDownloadDirInput(value)).toThrow(+ 'Invalid download directory',+ );+ }+ });++ it('rejects drive-relative paths on Windows', () => {+ if (process.platform === 'win32') {+ for (const value of [+ 'C:downloads',+ '\\downloads',+ '/downloads',+ '~/C:\\other',+ '~/C:other',+ '~/\\other',+ ]) {+ expect(() => validateDownloadDirInput(value)).toThrow(+ 'Invalid download directory',+ );+ }+ expect(validateDownloadDirInput('C:\\Downloads')).toBe('C:\\Downloads');+ }+ });+});