eve
Version:
Filesystem-first framework for durable backend AI agents that run anywhere.
1 lines • 524 B
JavaScript
function createClientUrl(e,t,n){let r=t.startsWith(`/`)?t:`/${t}`,i=formatSearch(n);if(isAbsoluteUrl(e)){let t=new URL(e);return t.pathname=`${trimTrailingSlash(t.pathname)}${r}`,t.search=i,t.hash=``,t.toString()}return`${trimTrailingSlash(e)}${r}${i}`}function isAbsoluteUrl(e){return/^[a-z][a-z\d+\-.]*:/i.test(e)}function trimTrailingSlash(e){return e===`/`?``:e.endsWith(`/`)?e.slice(0,-1):e}function formatSearch(e){return!e||Object.keys(e).length===0?``:`?${new URLSearchParams(e).toString()}`}export{createClientUrl};