mirror of
https://github.com/protomaps/PMTiles.git
synced 2026-02-04 10:51:07 +00:00
* Properly abort requests using AbortController * add basic adapter tests --------- Co-authored-by: Andrew Dassonville <dassonville.andrew@gmail.com>
This commit is contained in:
@@ -215,12 +215,13 @@ export class Protocol {
|
||||
}
|
||||
|
||||
if (this.metadata) {
|
||||
return {
|
||||
data: await instance.getTileJson(params.url),
|
||||
};
|
||||
const data = await instance.getTileJson(params.url);
|
||||
abortController.signal.throwIfAborted();
|
||||
return { data };
|
||||
}
|
||||
|
||||
const h = await instance.getHeader();
|
||||
abortController.signal.throwIfAborted();
|
||||
|
||||
if (h.minLon >= h.maxLon || h.minLat >= h.maxLat) {
|
||||
console.error(
|
||||
@@ -255,6 +256,7 @@ export class Protocol {
|
||||
|
||||
const header = await instance.getHeader();
|
||||
const resp = await instance?.getZxy(+z, +x, +y, abortController.signal);
|
||||
abortController.signal.throwIfAborted();
|
||||
if (resp) {
|
||||
return {
|
||||
data: new Uint8Array(resp.data),
|
||||
|
||||
@@ -355,7 +355,7 @@ export class FetchSource implements Source {
|
||||
let userAgent = "";
|
||||
if ("navigator" in globalThis) {
|
||||
//biome-ignore lint: cf workers
|
||||
userAgent = (globalThis as any).navigator.userAgent || "";
|
||||
userAgent = (globalThis as any).navigator?.userAgent ?? "";
|
||||
}
|
||||
const isWindows = userAgent.indexOf("Windows") > -1;
|
||||
const isChromiumBased = /Chrome|Chromium|Edg|OPR|Brave/.test(userAgent);
|
||||
|
||||
Reference in New Issue
Block a user