mirror of
https://github.com/maputnik/editor.git
synced 2026-08-25 14:37:27 +00:00
Update fontstacks URL according to https://github.com/klokantech/tileserver-gl/pull/104#issuecomment-274444087
This commit is contained in:
+10
-3
@@ -1,4 +1,5 @@
|
|||||||
import request from 'request'
|
import request from 'request'
|
||||||
|
import npmurl from 'url'
|
||||||
|
|
||||||
function loadJSON(url, defaultValue, cb) {
|
function loadJSON(url, defaultValue, cb) {
|
||||||
request({
|
request({
|
||||||
@@ -23,9 +24,15 @@ export function downloadGlyphsMetadata(urlTemplate, cb) {
|
|||||||
if(!urlTemplate) return cb([])
|
if(!urlTemplate) return cb([])
|
||||||
|
|
||||||
// Special handling because Tileserver GL serves the fontstacks metadata differently
|
// Special handling because Tileserver GL serves the fontstacks metadata differently
|
||||||
// https://github.com/klokantech/tileserver-gl/pull/104
|
// https://github.com/klokantech/tileserver-gl/pull/104#issuecomment-274444087
|
||||||
let url = urlTemplate.replace('/fonts/{fontstack}/{range}.pbf', '/fontstacks.json')
|
let urlObj = npmurl.parse(urlTemplate);
|
||||||
url = url.replace('{fontstack}/{range}.pbf', 'fontstacks.json')
|
const normPathPart = '/%7Bfontstack%7D/%7Brange%7D.pbf';
|
||||||
|
if(urlObj.pathname === normPathPart) {
|
||||||
|
urlObj.pathname = '/fontstacks.json';
|
||||||
|
} else {
|
||||||
|
urlObj.pathname = urlObj.pathname.replace(normPathPart, '.json');
|
||||||
|
}
|
||||||
|
let url = npmurl.format(urlObj);
|
||||||
|
|
||||||
loadJSON(url, [], cb)
|
loadJSON(url, [], cb)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user