From 7c91c699e4b6d687d56bf3bd976ef020a589ad11 Mon Sep 17 00:00:00 2001 From: Aaron Liu Date: Thu, 8 May 2025 19:16:51 +0800 Subject: [PATCH] fix: use regexp to explictly identify custom schem apps (https://github.com/cloudreve/Cloudreve/issues/2343) --- src/redux/thunks/viewer.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/redux/thunks/viewer.ts b/src/redux/thunks/viewer.ts index 29aa9fb..5ebbbd3 100644 --- a/src/redux/thunks/viewer.ts +++ b/src/redux/thunks/viewer.ts @@ -282,8 +282,8 @@ export function openCustomViewer(file: FileResponse, viewer: Viewer, preferredVe url = url.replace(`{$${key}}`, vars[key]); } - // if not start with http or https, it's a custom scheme - if (!url.startsWith("http") && !url.startsWith("https")) { + // if url matches custom scheme pattern like nplayer://xxx, use window.location.assign + if (/^(?!https?:\/\/)[a-zA-Z0-9]+:\/\//.test(url)) { window.location.assign(url); return; }