UNPKG

@lucidcms/core

Version:

The core of the Lucid CMS. It's responsible for spinning up the API and serving the CMS.

2 lines 713 B
import e from"../../../constants/constants.mjs";import{crc32 as t}from"node:zlib";const n=e=>(t(e)>>>0).toString(16).padStart(8,`0`),r=e=>Buffer.byteLength(e,`utf8`),i=(t,i)=>{if(i==null||!Number.isFinite(i))return{name:t,rawName:t};let a=Math.max(i,e.db.minTableNameByteLimit);if(r(t)<=a)return{name:t,rawName:t};let o=n(t),s=t.split(e.db.nameSeparator),c=`_${o}`;if(s.length>4){let n=`${s.slice(0,4).join(e.db.nameSeparator)}${c}`;if(r(n)<=a)return{name:n,rawName:t}}if(!t.startsWith(e.db.generatedIndexPrefix))return{name:t,rawName:t};let l=a-r(c),u=``;for(let e of t){let t=`${u}${e}`;if(r(t)>l)break;u=t}return{name:`${u}${c}`,rawName:t}};export{i as default}; //# sourceMappingURL=to-safe-table-name.mjs.map