@credo-ts/core
Version:
<p align="center"> <br /> <img alt="Credo Logo" src="https://github.com/openwallet-foundation/credo-ts/blob/c7886cb8377ceb8ee4efe8d264211e561a75072d/images/credo-logo.png" height="250px" /> </p> <h1 align="center"><b>Credo - Core</b></h1
1 lines • 1.78 kB
Source Map (JSON)
{"version":3,"file":"path.mjs","names":[],"sources":["../../src/utils/path.ts"],"sourcesContent":["/**\n * Extract directory from path (should also work with windows paths)\n *\n * @param path the path to extract the directory from\n * @returns the directory path\n */\nexport function getDirFromFilePath(path: string) {\n return path.substring(0, Math.max(path.lastIndexOf('/'), path.lastIndexOf('\\\\')))\n}\n\n/**\n * Combine multiple uri parts into a single uri taking into account slashes.\n *\n * @param parts the parts to combine\n * @returns the combined url\n */\nexport function joinUriParts(base: string, parts: string[]) {\n if (parts.length === 0) return base\n\n // take base without trailing /\n let combined = base.trim()\n combined = base.endsWith('/') ? base.slice(0, base.length - 1) : base\n\n for (const part of parts) {\n // Remove leading and trailing /\n let strippedPart = part.trim()\n strippedPart = strippedPart.startsWith('/') ? strippedPart.slice(1) : strippedPart\n strippedPart = strippedPart.endsWith('/') ? strippedPart.slice(0, strippedPart.length - 1) : strippedPart\n\n // Don't want to add if empty\n if (strippedPart === '') continue\n\n combined += `/${strippedPart}`\n }\n\n return combined\n}\n"],"mappings":";;;;;;;AAMA,SAAgB,mBAAmB,MAAc;CAC/C,OAAO,KAAK,UAAU,GAAG,KAAK,IAAI,KAAK,YAAY,GAAG,GAAG,KAAK,YAAY,IAAI,CAAC,CAAC;AAClF;;;;;;;AAQA,SAAgB,aAAa,MAAc,OAAiB;CAC1D,IAAI,MAAM,WAAW,GAAG,OAAO;CAG/B,IAAI,WAAW,KAAK,KAAK;CACzB,WAAW,KAAK,SAAS,GAAG,IAAI,KAAK,MAAM,GAAG,KAAK,SAAS,CAAC,IAAI;CAEjE,KAAK,MAAM,QAAQ,OAAO;EAExB,IAAI,eAAe,KAAK,KAAK;EAC7B,eAAe,aAAa,WAAW,GAAG,IAAI,aAAa,MAAM,CAAC,IAAI;EACtE,eAAe,aAAa,SAAS,GAAG,IAAI,aAAa,MAAM,GAAG,aAAa,SAAS,CAAC,IAAI;EAG7F,IAAI,iBAAiB,IAAI;EAEzB,YAAY,IAAI;CAClB;CAEA,OAAO;AACT"}