JSFiddle - React, Tailwind, and code Playground

JavaScript

var pathJoin = function(pathArr){
    return pathArr.map(function(path){
        if(path[0] === "/"){
            path = path.slice(1);        
        }
        if(path[path.length - 1] === "/"){
            path = path.slice(0, path.length - 1);   
        }
        return path;     
    }).join("/");
}
console.log(pathJoin(["http://example.org/path/","/to/","/resource/"]));