MCPcopy Create free account
hub / github.com/error311/FileRise / fr_normalize_profile_pic_url

Function fr_normalize_profile_pic_url

config/config.php:622–649  ·  view source on GitHub ↗
(string $url)

Source from the content-addressed store, hash-verified

620}
621
622function 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
651if (strpos(BASE_URL, 'yourwebsite') !== false) {
652 $defaultShare = "{$proto}://{$host}" . fr_with_base_path("/api/file/share.php");

Callers 5

siteConfigMethod · 0.85
getPortalBySlugMethod · 0.85
getUserMethod · 0.85
getPublicPortalMetaMethod · 0.85
sanitizeLogoUrlMethod · 0.85

Calls 1

fr_profile_pic_urlFunction · 0.85

Tested by

no test coverage detected