From 5c7e792561dec1087f31733337376ee9d13b05e5 Mon Sep 17 00:00:00 2001 From: Cursor Agent Date: Fri, 14 Nov 2025 18:02:20 +0000 Subject: [PATCH] Fix: Improve URL parsing and directory ID extraction Co-authored-by: vddafada --- dashboard/jquery/qaf_dashboard.js | 29 ++++++++++++++++++++--------- 1 file changed, 20 insertions(+), 9 deletions(-) diff --git a/dashboard/jquery/qaf_dashboard.js b/dashboard/jquery/qaf_dashboard.js index b1713cf..d943384 100644 --- a/dashboard/jquery/qaf_dashboard.js +++ b/dashboard/jquery/qaf_dashboard.js @@ -263,11 +263,16 @@ $.template("seleniumLogTemplate", seleniumLogTemplate); $.template("envInfoTemplate", envInfoTemplate); function getUrlVar(key) { - var result = new RegExp(key + "=([^&]*)", "i").exec(window.location.search); - - return (result && unescape(result[1] + "/test-results")) || "test-results"; - + if (result && typeof result[1] !== "undefined") { + try { + return decodeURIComponent(result[1]); + } catch (e) { + console.warn("Unable to decode url parameter:", key, e); + return result[1]; + } + } + return "test-results"; } var resultRootDir = getUrlVar("job");// "test-results"; var curResultDir = ""; @@ -459,9 +464,16 @@ function selectReport() { } function getIdFromDir(dir) { - var index = dir.indexOf("test-results") + "test-results/".lenght; - var endindex = dir.indexOf("json") - 1; - + var prefix = "test-results/"; + var index = dir.indexOf(prefix); + if (index === -1) { + return dir; + } + index += prefix.length; + var endindex = dir.indexOf(".json", index); + if (endindex === -1) { + endindex = dir.length; + } return dir.substring(index, endindex); } @@ -834,8 +846,7 @@ function loadDetailsTemplate(data, container) { function loadDetails(file, container) { return $.ajax({ dataType : "json", - url : file, - async : false + url : file }).success(function(data) { loadDetailsTemplate(data, container); });