(string $url)
| 620 | } |
| 621 | |
| 622 | function fr_normalize_profile_pic_url(string $url): string |
| 623 | { |
| 624 | $raw = trim((string)$url); |
| 625 | if ($raw === '') return ''; |
| 626 | |
| 627 | // Leave absolute http(s) URLs unchanged. |
| 628 | if (preg_match('~^https?://~i', $raw)) return $raw; |
| 629 | |
| 630 | // Ensure a leading slash for site-relative paths. |
| 631 | if ($raw[0] !== '/') $raw = '/' . ltrim($raw, '/'); |
| 632 | |
| 633 | $base = defined('FR_BASE_PATH') ? (string)FR_BASE_PATH : ''; |
| 634 | $prefix = ''; |
| 635 | if ($base !== '' && $raw !== $base && strpos($raw, $base . '/') === 0) { |
| 636 | $prefix = $base; |
| 637 | $raw = substr($raw, strlen($base)); |
| 638 | if ($raw === '') $raw = '/'; |
| 639 | } |
| 640 | |
| 641 | if (preg_match('~^/uploads/profile_pics/([^/?#]+)~', $raw, $m)) { |
| 642 | return $prefix . fr_profile_pic_url($m[1]); |
| 643 | } |
| 644 | if (preg_match('~^/api/public/profilePic\.php\\?file=~', $raw)) { |
| 645 | return $prefix . $raw; |
| 646 | } |
| 647 | |
| 648 | return $prefix . $raw; |
| 649 | } |
| 650 | |
| 651 | if (strpos(BASE_URL, 'yourwebsite') !== false) { |
| 652 | $defaultShare = "{$proto}://{$host}" . fr_with_base_path("/api/file/share.php"); |
no test coverage detected