UNPKG

832 BJavaScriptView Raw
1"use strict";
2Object.defineProperty(exports, "__esModule", { value: true });
3exports.safeId = exports.unprefixId = exports.prefixId = exports.isDraftId = void 0;
4function isDraftId(id) {
5 return id.startsWith('drafts.');
6}
7exports.isDraftId = isDraftId;
8exports.prefixId = function (id) { return (id.startsWith('drafts.') ? id : "drafts." + id); };
9exports.unprefixId = function (id) { return id.replace(/^drafts\./, ''); };
10exports.safeId = function (id, makeSafe) {
11 return /^(image|file)-[a-z0-9]{32,}-/.test(id)
12 ? // Use raw IDs for assets as we might use these with asset tooling
13 id
14 : // Prefix Gatsbyfied IDs with a dash as it's not allowed in Sanity,
15 // thus enabling easy checks for Gatsby vs Sanity IDs
16 "-" + makeSafe(id);
17};
18//# sourceMappingURL=documentIds.js.map
\No newline at end of file