diff options
-rw-r--r-- | fietsboek/views/tileproxy.py | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/fietsboek/views/tileproxy.py b/fietsboek/views/tileproxy.py index 999b04f..0264284 100644 --- a/fietsboek/views/tileproxy.py +++ b/fietsboek/views/tileproxy.py @@ -8,10 +8,10 @@ Additionally, this protects the users' IP, as only fietsboek can see it. """ import datetime import logging -import random import threading from itertools import chain from typing import List, Optional +from urllib.parse import quote import requests from pydantic import AnyUrl, TypeAdapter @@ -331,7 +331,13 @@ def tile_proxy(request): LOGGER.debug("Aborted attempt to contact %s due to previous timeouts", provider) raise HTTPGatewayTimeout(f"Avoiding request to {provider}") - url = tile_sources[provider].url.unicode_string().format(x=x, y=y, z=z, s=random.choice("abc")) + url = ( + tile_sources[provider] + .url.unicode_string() + .replace(quote("{x}"), str(x)) + .replace(quote("{y}"), str(y)) + .replace(quote("{z}"), str(z)) + ) # Avoid doing actual requests during tests if url.startswith("http://localhost:0"): LOGGER.debug("Skipping tile proxy request for testing URL") |