Use a neutral compact switch codec and clarify provider size limits

This commit is contained in:
Sameh Khamis committed 2026-10-09 18:47:04 -07:00
1 parent fbe118aab9
commit 3ba8c6d61b
11 files changed
+127 -98

No files matched your search

+13 -2
View File
@@ -1,4 +1,4 @@
import { encodeProviderSwitches } from './providerSwitches.js';
import { encodeIdSwitches } from '../../data/idSwitches.js';
/**
* The contract an imagery provider registers with the Street Level layer.
@@ -128,7 +128,18 @@ export function validateProviders(providers) {
prefixes.push(provider.pickPrefix);
}
// Validate the complete bounded share field once, before any instance exists.
encodeProviderSwitches(providers.map(({ id }) => [id, true]));
try {
encodeIdSwitches(
providers
.filter(({ id }) => id !== 'mapillary')
.map(({ id }) => [id, true]),
);
} catch (error) {
if (!(error instanceof RangeError)) throw error;
throw new RangeError(
'Street Level provider IDs cannot fit in the 256-character share-link field; use shorter IDs or fewer providers',
);
}
return Object.freeze([...providers]);
}