Skip to content

Commit

Permalink
Upd: Support testsuite behind reverse proxy
Browse files Browse the repository at this point in the history
  • Loading branch information
jcorporation committed Oct 9, 2024
1 parent 055a2e7 commit 11f7380
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 3 deletions.
4 changes: 3 additions & 1 deletion htdocs/test/apitest.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
https://github.com/jcorporation/mympd
*/

const subdir = window.location.pathname.replace('/test/apitest.html', '').replace(/\/$/, '');

const cmds = Object.keys(APImethods);
let i = 0;
let error = 0;
Expand Down Expand Up @@ -51,7 +53,7 @@ async function sendAPI(method) {
const request = {"jsonrpc": "2.0", "id": 0, "method": method, "params": apiParamsToObject(APImethods[method].params)};
document.getElementsByTagName('h5')[0].textContent = 'Running ' + JSON.stringify(request);
time_start = new Date().getTime();
const uri = '/api/default';
const uri = subdir + '/api/default';
const response = await fetch(uri, {
method: 'POST',
mode: 'same-origin',
Expand Down
4 changes: 3 additions & 1 deletion htdocs/test/fuzzer.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ let t = 0;
const blns_len = blns.length;
let cmds;

const subdir = window.location.pathname.replace('/test/fuzzer.html', '').replace(/\/$/, '');

function defineCmds() {
let newCmds = [];
for (const method in APImethods) {
Expand Down Expand Up @@ -99,7 +101,7 @@ async function sendAPI(id) {
}
const request = cmds[id];
let sleep = 0;
const uri = '/api/default';
const uri = subdir + '/api/default';
const response = await fetch(uri, {
method: 'POST',
mode: 'same-origin',
Expand Down
4 changes: 3 additions & 1 deletion htdocs/test/manual.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@

/* global cmds */

const subdir = window.location.pathname.replace('/test/manual.html', '').replace(/\/$/, '');

//escapes html characters to avoid xss
function e(x) {
if (x!== undefined && isNaN(x)) {
Expand Down Expand Up @@ -119,7 +121,7 @@ async function sendAPI() {
if (APImethods[method].params !== undefined) {
request.params = formToParams(APImethods[method].params, '');
}
const uri = '/api/' + partition;
const uri = subdir + '/api/' + partition;
document.getElementById('requestText').textContent = JSON.stringify(request);
const time_start = new Date().getTime();
const response = await fetch(uri, {
Expand Down

0 comments on commit 11f7380

Please sign in to comment.