function s(t,e=!1){let r=t;e&&r.startsWith("//")&&(r="http:"+t);try{return URL?.parse?URL?.parse(r):new URL(r)}catch(n){return console.error("Invalid URL: %s",r,n),null}}function o(t){try{const e=new URL(t);let r=e.pathname;if(r.endsWith("/"))return e.origin+r;const n=r.lastIndexOf("/");return n!==-1?(r=r.substring(0,n+1),e.origin+r):e.origin+"/"}catch(e){console.error(`Invalid URL: ${t}`,e);return}}export{o as getUrlDirname,s as urlParse};
