mirror of
https://github.com/jokob-sk/NetAlertX.git
synced 2026-02-23 18:56:05 -05:00
Refactor: Clean up whitespace in deep link handling functions and tests
This commit is contained in:
@@ -44,13 +44,13 @@ function validate_local_path(?string $encoded): string {
|
||||
function extract_hash_from_path(string $path): array {
|
||||
/*
|
||||
Split a path into path and hash components.
|
||||
|
||||
|
||||
For deep links encoded in the 'next' parameter like /devices.php#device-123,
|
||||
extract the hash fragment so it can be properly included in the redirect.
|
||||
|
||||
|
||||
Args:
|
||||
path: Full path potentially with hash (e.g., "/devices.php#device-123")
|
||||
|
||||
|
||||
Returns:
|
||||
Array with keys 'path' (without hash) and 'hash' (with # prefix, or empty string)
|
||||
*/
|
||||
@@ -67,7 +67,7 @@ function append_hash(string $url): string {
|
||||
if (!empty($parts['hash'])) {
|
||||
return $parts['path'] . $parts['hash'];
|
||||
}
|
||||
|
||||
|
||||
// Fall back to POST url_hash (for browser-captured hashes)
|
||||
if (!empty($_POST['url_hash'])) {
|
||||
$sanitized = preg_replace('/[^#a-zA-Z0-9_\-]/', '', $_POST['url_hash']);
|
||||
|
||||
@@ -137,7 +137,7 @@ def test_login_redirects_to_devices(driver):
|
||||
|
||||
def test_login_with_deep_link_preserves_hash(driver):
|
||||
"""Test: Login with deep link (?next=...) preserves the URL fragment hash
|
||||
|
||||
|
||||
When a user logs in from a deep link URL (e.g., ?next=base64(devices.php%23device-123)),
|
||||
they should be redirected to the target page with the hash fragment intact.
|
||||
"""
|
||||
@@ -162,7 +162,7 @@ def test_login_with_deep_link_preserves_hash(driver):
|
||||
# Check that we're on the right page with the hash preserved
|
||||
current_url = driver.current_url
|
||||
print(f"URL after login with deep link: {current_url}")
|
||||
|
||||
|
||||
if '/devices.php' not in current_url:
|
||||
pytest.skip(f"Login failed or redirect not configured. URL: {current_url}")
|
||||
|
||||
@@ -172,7 +172,7 @@ def test_login_with_deep_link_preserves_hash(driver):
|
||||
|
||||
def test_login_with_deep_link_to_network_page(driver):
|
||||
"""Test: Login with deep link to network.php page preserves hash
|
||||
|
||||
|
||||
User can login with a deep link to the network page (e.g., network.php#settings-panel),
|
||||
and should be redirected to that page with the hash fragment intact.
|
||||
"""
|
||||
@@ -197,7 +197,7 @@ def test_login_with_deep_link_to_network_page(driver):
|
||||
# Check that we're on the right page with the hash preserved
|
||||
current_url = driver.current_url
|
||||
print(f"URL after login with network.php deep link: {current_url}")
|
||||
|
||||
|
||||
if '/network.php' not in current_url:
|
||||
pytest.skip(f"Login failed or redirect not configured. URL: {current_url}")
|
||||
|
||||
@@ -233,7 +233,7 @@ def test_login_without_next_parameter(driver):
|
||||
|
||||
def test_url_hash_hidden_input_present(driver):
|
||||
"""Test: URL fragment hash field is present in login form
|
||||
|
||||
|
||||
The hidden url_hash input field is used to capture and preserve
|
||||
URL hash fragments during form submission and redirect.
|
||||
"""
|
||||
|
||||
Reference in New Issue
Block a user