Fix find-webclient for baseurls.

This commit is contained in:
Izzie Walton 2024-06-07 09:16:29 -04:00
parent 1075ff722c
commit 3f31831a7e

View File

@ -7,7 +7,7 @@ async function tryConnect(server) {
}
server = server.replace(/\/+$/, "");
const url = new URL("/System/Info/Public", server);
const url = server + "/System/Info/Public";
const response = await fetch(url);
if (response.ok && (await response.json()).Id) {
const htmlResponse = await fetch(server);
@ -29,16 +29,16 @@ async function tryConnect(server) {
const base = doc.createElement("base");
base.href = webUrl
doc.head.insertBefore(base, doc.head.firstChild);
const oldPushState = window.history.pushState;
window.history.pushState = function(state, title, url) {
url = (new URL(url, realUrl)).toString();
url = url ? (new URL(url, realUrl)).toString() : realUrl;
return oldPushState.call(window.history, state, title, url);
};
const oldReplaceState = window.history.replaceState;
window.history.replaceState = function(state, title, url) {
url = (new URL(url, realUrl)).toString();
url = url ? (new URL(url, realUrl)).toString() : realUrl;
return oldReplaceState.call(window.history, state, title, url);
};