Fix code quality violations and enhance ROUTE-EXISTS-01 rule
Implement JQHTML function cache ID system and fix bundle compilation Implement underscore prefix for system tables Fix JS syntax linter to support decorators and grant exception to Task system SPA: Update planning docs and wishlists with remaining features SPA: Document Navigation API abandonment and future enhancements Implement SPA browser integration with History API (Phase 1) Convert contacts view page to SPA action Convert clients pages to SPA actions and document conversion procedure SPA: Merge GET parameters and update documentation Implement SPA route URL generation in JavaScript and PHP Implement SPA bootstrap controller architecture Add SPA routing manual page (rsx:man spa) Add SPA routing documentation to CLAUDE.md Phase 4 Complete: Client-side SPA routing implementation Update get_routes() consumers for unified route structure Complete SPA Phase 3: PHP-side route type detection and is_spa flag Restore unified routes structure and Manifest_Query class Refactor route indexing and add SPA infrastructure Phase 3 Complete: SPA route registration in manifest Implement SPA Phase 2: Extract router code and test decorators Rename Jqhtml_Component to Component and complete SPA foundation setup 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -473,6 +473,10 @@ function rsx_view($id, $data = [], $merge_data = [])
|
||||
// Handle different view locations
|
||||
if (str_starts_with($view_name, 'resources/views/')) {
|
||||
$view_name = substr($view_name, strlen('resources/views/'));
|
||||
} elseif (str_starts_with($view_name, 'app/RSpade/')) {
|
||||
// For framework views, use namespace format
|
||||
// The namespace 'rspade' is registered in Rsx_Framework_Provider
|
||||
$view_name = 'rspade::' . substr($view_name, strlen('app/RSpade/'));
|
||||
} elseif (str_starts_with($view_name, 'rsx/')) {
|
||||
// For RSX views, use namespace format
|
||||
// The namespace 'rsx' is registered in RsxServiceProvider
|
||||
@@ -1389,3 +1393,101 @@ function duration_to_human($seconds, $round_to_whole_value = false)
|
||||
return count($parts) > 1 ? $parts[0] . " and " . $parts[1] : (count($parts) > 0 ? $parts[0] : "less than a second");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert a full URL to short URL by removing protocol
|
||||
*
|
||||
* Strips http:// or https:// from the beginning of the URL if present.
|
||||
* Leaves the URL alone if it doesn't start with either protocol.
|
||||
* Removes trailing slash if there is no path.
|
||||
*
|
||||
* @param string|null $url URL to convert
|
||||
* @return string|null Short URL without protocol
|
||||
*/
|
||||
function full_url_to_short_url(?string $url): ?string
|
||||
{
|
||||
if ($url === null || $url === '') {
|
||||
return $url;
|
||||
}
|
||||
|
||||
// Remove http:// or https:// from the beginning
|
||||
if (stripos($url, 'http://') === 0) {
|
||||
$url = substr($url, 7);
|
||||
} elseif (stripos($url, 'https://') === 0) {
|
||||
$url = substr($url, 8);
|
||||
}
|
||||
|
||||
// Remove trailing slash if there is no path (just domain)
|
||||
// Check if URL is just domain with trailing slash (no path after slash)
|
||||
if (substr($url, -1) === '/' && substr_count($url, '/') === 1) {
|
||||
$url = rtrim($url, '/');
|
||||
}
|
||||
|
||||
return $url;
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert a short URL to full URL by adding protocol
|
||||
*
|
||||
* Adds http:// to the beginning of the URL if it lacks a protocol.
|
||||
* Leaves URLs with existing http:// or https:// unchanged.
|
||||
* Adds trailing slash if there is no path.
|
||||
*
|
||||
* @param string|null $url URL to convert
|
||||
* @return string|null Full URL with protocol
|
||||
*/
|
||||
function short_url_to_full_url(?string $url): ?string
|
||||
{
|
||||
if ($url === null || $url === '') {
|
||||
return $url;
|
||||
}
|
||||
|
||||
// Check if URL already has a protocol
|
||||
if (stripos($url, 'http://') === 0 || stripos($url, 'https://') === 0) {
|
||||
$full_url = $url;
|
||||
} else {
|
||||
// Add http:// protocol
|
||||
$full_url = 'http://' . $url;
|
||||
}
|
||||
|
||||
// Add trailing slash if there is no path (just domain)
|
||||
// Check if URL has no slash after the domain
|
||||
$without_protocol = preg_replace('#^https?://#i', '', $full_url);
|
||||
if (strpos($without_protocol, '/') === false) {
|
||||
$full_url .= '/';
|
||||
}
|
||||
|
||||
return $full_url;
|
||||
}
|
||||
|
||||
/**
|
||||
* Validate a short URL format
|
||||
*
|
||||
* Validates that a URL (without protocol) looks like a valid domain.
|
||||
* Requirements:
|
||||
* - Must contain at least one dot (.)
|
||||
* - Must not contain spaces
|
||||
* - Empty strings are considered valid (optional field)
|
||||
*
|
||||
* @param string|null $url Short URL to validate
|
||||
* @return bool True if valid, false otherwise
|
||||
*/
|
||||
function validate_short_url(?string $url): bool
|
||||
{
|
||||
// Empty strings are valid (optional field)
|
||||
if ($url === null || $url === '') {
|
||||
return true;
|
||||
}
|
||||
|
||||
// Must not contain spaces
|
||||
if (strpos($url, ' ') !== false) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Must contain at least one dot (domain.extension)
|
||||
if (strpos($url, '.') === false) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user