UNPKG

decocms

Version:

Deco CMS — Self-hostable MCP Gateway for managing AI connections and tools

2 lines (1 loc) • 847 B
function l(e){return e.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"")}function c(e,n){return`${e}--${l(n)}`}const i=new Set(["localhost","127.0.0.1","[::1]"]);function h(e){return e.split("/").filter(Boolean).at(-1)??e}function u(e,n){const a=l(n);if(!a)return null;let t;try{t=new URL(e)}catch{return null}const s=t.hostname;if(i.has(s))t.hostname=`${a}.localhost`;else if(s.endsWith(".localhost"))t.hostname=`${a}.${s}`;else{const[o,...r]=s.split(".");if(!o||r.length===0)return null;t.hostname=[c(o,n),...r].join(".")}return t.pathname="/",t.search="",t.hash="",t.toString()}function p(e,n){const a=new URL(e),t=n.trim(),s=t.startsWith("/")?t:`/${t}`,[o="/",r=""]=s.split("?");return a.pathname=o,a.search=r?`?${r}`:"",a.toString()}function m(e){return e.trim().replace(/^\.?\/+|\/+$/g,"")}export{h as a,u as b,m as n,p as w};