@sanity/client 6.20.2-beta.1 → 6.20.2-beta.2

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.
@@ -873,9 +873,9 @@ function optionsFromFile(opts, file) {
873
873
  opts
874
874
  );
875
875
  }
876
- const UNSHARDED_URL_RE = /^https:\/\/([a-z0-9]+)\.api\.(sanity\..*)/, SHARDED_URL_RE = /^https:\/\/[a-z0-9]+\.api\.s(\d+)\.sanity\.(.*)/, domainSharder = getDomainSharder();
876
+ const UNSHARDED_URL_RE = /^https:\/\/([a-z0-9]+)\.api\.(sanity\..*)/, SHARDED_URL_RE = /^https:\/\/[a-z0-9]+\.api\.r(\d+)\.sanity\.(.*)/, domainSharder = getDomainSharder();
877
877
  function getDomainSharder(initialBuckets) {
878
- const buckets = new Array(10).fill(0, 0);
878
+ const buckets = new Array(3).fill(0, 0);
879
879
  function incrementBucketForUrl(url) {
880
880
  const shard = getShardFromUrl(url);
881
881
  shard !== null && buckets[shard]++;
@@ -892,11 +892,11 @@ function getDomainSharder(initialBuckets) {
892
892
  (smallest, count, index) => count < buckets[smallest] ? index : smallest,
893
893
  0
894
894
  );
895
- return `https://${projectId2}.api.s${bucket}.${rest}`;
895
+ return `https://${projectId2}.api.r${bucket + 1}.${rest}`;
896
896
  }
897
897
  function getShardFromUrl(url) {
898
898
  const [isMatch, shard] = url.match(SHARDED_URL_RE) || [];
899
- return isMatch ? parseInt(shard, 10) : null;
899
+ return isMatch ? parseInt(shard, 10) - 1 : null;
900
900
  }
901
901
  return {
902
902
  middleware: {