mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-05 02:44:02 +00:00
fix(maps): avoid 404 on keyless Google tiles-token probe (#1066)
Return an uncached unavailable-token response for keyless Google tile-token requests. Contribution by @dvilrgamerz.
This commit is contained in:
1 parent
06c51d3438
commit
a7fcb3c232
8 files changed
+147
-4
No files matched your search
@@ -38,6 +38,7 @@ export function createGoogleTokenSource({
|
||||
headers: { Accept: 'application/json' },
|
||||
cache: 'no-store',
|
||||
});
|
||||
if (response.status === 204) return null;
|
||||
if (!response.ok) {
|
||||
await response.body?.cancel();
|
||||
return null;
|
||||
|
||||
@@ -79,3 +79,12 @@ test('a server that does not offer tokens yields none', async () => {
|
||||
assert.equal(await createGoogleTokenSource({ fetchImpl }).token(), null);
|
||||
}
|
||||
});
|
||||
|
||||
test('an empty 204 response explicitly means no Google token is available', async () => {
|
||||
const { calls, fetchImpl } = server([
|
||||
new Response(null, { status: 204, headers: { 'Cache-Control': 'no-store' } }),
|
||||
]);
|
||||
const tokens = createGoogleTokenSource({ fetchImpl });
|
||||
assert.equal(await tokens.token(), null);
|
||||
assert.deepEqual(calls, [GOOGLE_TOKEN_PATH]);
|
||||
});
|
||||
Reference in new issue
Block a user