HEX
Server: Apache/2.4.68 (Debian)
System: Linux as-cs-widget-demo-us-central1 6.1.0-44-cloud-amd64 #1 SMP PREEMPT_DYNAMIC Debian 6.1.164-1 (2026-03-09) x86_64
User: root (0)
PHP: 8.2.32
Disabled: NONE
Upload Files
File: //proc/self/cwd/wp-content/plugins/allspice/includes/url_key.php
<?php
// includes/url_key.php
if (!defined('ABSPATH')) exit;

function allspice_url_key(string $u): string {
    $u = trim($u ?? '');
    if ($u === '') return '';
    try {
        $parts = wp_parse_url($u);
        if (!is_array($parts)) {
            return trim($u);
        }
        $host = strtolower((string)($parts['host'] ?? ''));
        if ($host === '') {
            return trim($u);
        }
        if (strpos($host, 'www.') === 0) {
            $host = substr($host, 4);
        }
        $host = rtrim($host, '.');
        $path = (string)($parts['path'] ?? '');
        $path = preg_replace('#/{2,}#', '/', $path) ?? $path;
        $path = rtrim($path, '/');
        $path = preg_replace('#/index\.html?$#i', '', $path) ?? $path;
        $path = preg_replace('#\.html?$#i', '', $path) ?? $path;
        return $host . $path;
    } catch (\Throwable $e) {
        return trim($u);
    }
}