@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.
- package/dist/index.browser.cjs +4 -4
- package/dist/index.browser.cjs.map +1 -1
- package/dist/index.browser.js +4 -4
- package/dist/index.browser.js.map +1 -1
- package/dist/index.cjs +5 -5
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +5 -5
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/src/http/domainSharding.ts +9 -4
- package/umd/sanityClient.js +4 -4
- package/umd/sanityClient.min.js +1 -1
package/dist/index.browser.cjs
CHANGED
|
@@ -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\.
|
|
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(
|
|
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.
|
|
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: {
|