JSFiddle - React, Tailwind, and code Playground

JavaScript

function RemoveLastDirectoryPartOf(the_url)
{
    var the_arr = the_url.split('/');
    the_arr.pop();
    return( the_arr.join('/') );
}



alert(RemoveLastDirectoryPartOf('https://my_ip_address:port/site.php?path=/path/to/my/folder'));