@prismicio/types-internal 4.2.0-pr.15.33ed5f7 → 4.2.0-pr.15.ea90d6d
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
declare namespace repository_d_exports {
|
|
2
|
-
export {
|
|
2
|
+
export { serializeID };
|
|
3
3
|
}
|
|
4
|
-
declare function
|
|
4
|
+
declare function serializeID(input: string): string;
|
|
5
5
|
//#endregion
|
|
6
6
|
export { repository_d_exports };
|
|
7
7
|
//# sourceMappingURL=repository.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"repository.d.ts","names":[],"sources":["../../src/helpers/repository.ts"],"mappings":";;;iBAGgB,
|
|
1
|
+
{"version":3,"file":"repository.d.ts","names":[],"sources":["../../src/helpers/repository.ts"],"mappings":";;;iBAGgB,WAAA,CAAY,KAAA"}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { __exportAll } from "../_virtual/_rolldown/runtime.js";
|
|
2
2
|
//#region src/helpers/repository.ts
|
|
3
|
-
var repository_exports = /* @__PURE__ */ __exportAll({
|
|
3
|
+
var repository_exports = /* @__PURE__ */ __exportAll({ serializeID: () => serializeID });
|
|
4
4
|
const MIN_LENGTH = 4;
|
|
5
5
|
const MAX_LENGTH = 63;
|
|
6
|
-
function
|
|
6
|
+
function serializeID(input) {
|
|
7
7
|
const normalized = input.trim().normalize("NFD").replace(/\p{M}/gu, "").toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-+|-+$/g, "");
|
|
8
8
|
const truncated = normalized.length > MAX_LENGTH ? normalized.slice(0, MAX_LENGTH).replace(/-+$/, "") : normalized;
|
|
9
9
|
if (truncated.length < MIN_LENGTH) throw new Error(`Cannot serialize "${input}" to a repository ID: result must be between ${MIN_LENGTH} and ${MAX_LENGTH} characters.`);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"repository.js","names":[],"sources":["../../src/helpers/repository.ts"],"sourcesContent":["const MIN_LENGTH = 4\nconst MAX_LENGTH = 63\n\nexport function
|
|
1
|
+
{"version":3,"file":"repository.js","names":[],"sources":["../../src/helpers/repository.ts"],"sourcesContent":["const MIN_LENGTH = 4\nconst MAX_LENGTH = 63\n\nexport function serializeID(input: string): string {\n\tconst normalized = input\n\t\t.trim()\n\t\t.normalize(\"NFD\")\n\t\t.replace(/\\p{M}/gu, \"\")\n\t\t.toLowerCase()\n\t\t.replace(/[^a-z0-9]+/g, \"-\")\n\t\t.replace(/^-+|-+$/g, \"\")\n\n\tconst truncated =\n\t\tnormalized.length > MAX_LENGTH\n\t\t\t? normalized.slice(0, MAX_LENGTH).replace(/-+$/, \"\")\n\t\t\t: normalized\n\n\tif (truncated.length < MIN_LENGTH) {\n\t\tthrow new Error(\n\t\t\t`Cannot serialize \"${input}\" to a repository ID: result must be between ${MIN_LENGTH} and ${MAX_LENGTH} characters.`,\n\t\t)\n\t}\n\n\treturn truncated\n}\n"],"mappings":";;;AAAA,MAAM,aAAa;AACnB,MAAM,aAAa;AAEnB,SAAgB,YAAY,OAAuB;CAClD,MAAM,aAAa,MACjB,MAAM,CACN,UAAU,MAAM,CAChB,QAAQ,WAAW,GAAG,CACtB,aAAa,CACb,QAAQ,eAAe,IAAI,CAC3B,QAAQ,YAAY,GAAG;CAEzB,MAAM,YACL,WAAW,SAAS,aACjB,WAAW,MAAM,GAAG,WAAW,CAAC,QAAQ,OAAO,GAAG,GAClD;AAEJ,KAAI,UAAU,SAAS,WACtB,OAAM,IAAI,MACT,qBAAqB,MAAM,+CAA+C,WAAW,OAAO,WAAW,cACvG;AAGF,QAAO"}
|
package/package.json
CHANGED