refactor: improve URL handling in RebootingOverlay component

This commit is contained in:
Adam Shiervani 2025-10-23 15:16:53 +00:00
parent 9a4d061034
commit 03a05c135a
1 changed files with 8 additions and 2 deletions

View File

@ -475,8 +475,14 @@ export function RebootingOverlay({ show, postRebootAction }: RebootingOverlayPro
if (response.ok) { if (response.ok) {
// Device is available, redirect to the specified URL // Device is available, redirect to the specified URL
console.log('Device is available, redirecting to:', postRebootAction.redirectUrl); console.log('Device is available, redirecting to:', postRebootAction.redirectUrl);
window.location.href = postRebootAction.redirectUrl;
window.location.reload(); // URL constructor handles all cases elegantly:
// - Absolute paths: resolved against current origin
// - Protocol-relative URLs: resolved with current protocol
// - Fully qualified URLs: used as-is
const targetUrl = new URL(postRebootAction.redirectUrl, window.location.origin);
window.location.href = targetUrl.href;
} }
} catch (err) { } catch (err) {
// Ignore errors - they're expected while device is rebooting // Ignore errors - they're expected while device is rebooting