From 568ae4fe7fd88ec6c69f7f908a3af7f41af96575 Mon Sep 17 00:00:00 2001 From: Brandon Liu Date: Wed, 31 Mar 2021 15:15:06 +0800 Subject: [PATCH] allow status code 200 for gh pages --- examples/leaflet.html | 2 +- js/pmtiles.js | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/examples/leaflet.html b/examples/leaflet.html index a5033c9..74e4e74 100644 --- a/examples/leaflet.html +++ b/examples/leaflet.html @@ -18,7 +18,7 @@
diff --git a/js/pmtiles.js b/js/pmtiles.js index b775925..2c5bc83 100644 --- a/js/pmtiles.js +++ b/js/pmtiles.js @@ -40,10 +40,11 @@ } class PMTiles { - constructor(url) { + constructor(url, options) { this.url = url this.root = fetch(this.url,{method:'HEAD',headers:{Range:'bytes=0-511999'}}).then(resp => { - if (resp.status == 206) { // this does not work on Azure, it returns 200 instead of 206 + // for servers like Azure, GH Pages which return 200 instead of 206 + if (resp.status == 206 || (resp.status == 200 && options.allow_200)) { console.log("Check succeeded: server supports byte ranges") return fetch(this.url,{headers:{Range:'bytes=0-511999'}}).then(resp => { return resp.arrayBuffer()