From 683960883ec102b12e0c0a8c8e7c99db0f24590f Mon Sep 17 00:00:00 2001 From: "panxuchen.pxc" Date: Tue, 30 Jul 2024 10:57:28 +0800 Subject: [PATCH] fix script loading in studio --- src/agentscope/studio/static/js/index.js | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/src/agentscope/studio/static/js/index.js b/src/agentscope/studio/static/js/index.js index f4c1a64fb..aa9876e43 100644 --- a/src/agentscope/studio/static/js/index.js +++ b/src/agentscope/studio/static/js/index.js @@ -11,11 +11,18 @@ let activeExpanded = false; // Check if the script is already loaded function isScriptLoaded(src) { + let curURL = new URL(src, window.location.href).pathname; return Array.from(document.scripts).some((script) => { - return ( - new URL(script.src).pathname === - new URL(src, window.location.href).pathname - ); + try { + let existURL = new URL(script.src).pathname; + return existURL === curURL; + } catch (error) { + console.warn( + "Error occurred when checking if the script is loaded: ", + error + ); + return false; + } }); }