- if( asprintf( &p_sys->psz_rtsp_url, "%s/", psz_url ) == -1 )
- {
- p_sys->psz_rtsp_url = NULL;
- free( psz_url );
- goto error;
- }
- free( psz_url );
+ vlc_url_t url;
+ vlc_UrlParse( &url, psz_url, 0 );
+ free( psz_url );
+
+ if( url.psz_path == NULL )
+ p_sys->psz_rtsp_path = strdup( "/" );
+ else
+ if( !( strlen( url.psz_path ) > 0
+ && url.psz_path[strlen( url.psz_path ) - 1] == '/' ) )
+ {
+ if( asprintf( &p_sys->psz_rtsp_path, "%s/", url.psz_path ) == -1 )
+ {
+ p_sys->psz_rtsp_path = NULL;
+ vlc_UrlClean( &url );
+ goto error;
+ }
+ }
+ else
+ p_sys->psz_rtsp_path = strdup( url.psz_path );
+
+ vlc_UrlClean( &url );