Skip to content

Commit ad5eb4b

Browse files
authored
Dashboard: Add suggested url via url param when missing stored url (#1309)
1 parent 2fefe0f commit ad5eb4b

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

dashboard/src/entrypoint/main.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,20 +6,26 @@ async function main() {
66
let url = "";
77

88
// Detect if we're running in the (production) webserver included in the matter server or not.
9-
const isProductionServer = location.href.includes(":5580") || location.href.includes("hassio_ingress") || location.href.includes("/api/ingress/");
9+
const isProductionServer = location.origin.includes(":5580") || location.href.includes("hassio_ingress") || location.href.includes("/api/ingress/");
1010

1111
if (!isProductionServer) {
1212
// development server, ask for url to matter server
1313
let storageUrl = localStorage.getItem("matterURL");
1414
if (!storageUrl) {
15+
const urlParams = new URLSearchParams(window.location.search);
16+
const suggestedUrl = urlParams.get('url');
1517
storageUrl = prompt(
1618
"Enter Websocket URL to a running Matter Server",
17-
"ws://localhost:5580/ws"
19+
suggestedUrl || "ws://localhost:5580/ws"
1820
);
1921
if (!storageUrl) {
2022
alert("Unable to connect without URL");
2123
return;
2224
}
25+
if (suggestedUrl) {
26+
// Remove suggested url from address without redirecting
27+
history.pushState({}, "", window.location.pathname);
28+
}
2329
localStorage.setItem("matterURL", storageUrl);
2430
}
2531
url = storageUrl;

0 commit comments

Comments
 (0)