String urlToPath(String url) { if (url == null) return ''; return (url.split('/') ..removeLast() ..add('')).join('/'); }