optional theme in tile server URLs

theme is not optional in core because it has optional access restrictions already, but in an actual deployment all tiles are loaded through the tile server, and this is only for backwards compatibility with external services
This commit is contained in:
Gwendolyn 2024-01-06 18:58:13 +01:00
parent 59317f9a42
commit 0e72967698

View file

@ -32,7 +32,7 @@ if os.environ.get('C3NAV_LOGFILE'):
class TileServer:
def __init__(self):
self.path_regex = re.compile(r'^/(\d+)/(-?\d+)/(-?\d+)/(-?\d+)/(-?\d+).png$')
self.path_regex = re.compile(r'^/(\d+)/(-?\d+)/(-?\d+)/(-?\d+)(/(-?\d+))?.png$')
self.cookie_regex = re.compile(r'(^| )c3nav_tile_access="?([^;" ]+)"?')
@ -239,7 +239,9 @@ class TileServer:
if match is None:
return self.not_found(start_response, b'invalid tile path.')
level, zoom, x, y, theme = match.groups()
level, zoom, x, y, _, theme = match.groups()
if theme is None:
theme = 0
zoom = int(zoom)
if not (-2 <= zoom <= 5):