diff --git a/easy_pdf/rendering.py b/easy_pdf/rendering.py index a068dac..2cb9cf5 100644 --- a/easy_pdf/rendering.py +++ b/easy_pdf/rendering.py @@ -24,14 +24,16 @@ def fetch_resources(uri, rel): """ Retrieves embeddable resource from given ``uri``. - For now only local resources (images, fonts) are supported. - :param str uri: path or url to image or font resource :returns: path to local resource file. :rtype: str :raises: :exc:`~easy_pdf.exceptions.UnsupportedMediaPathException` """ - if settings.STATIC_URL and uri.startswith(settings.STATIC_URL): + # For protocol relative, http and https URLs, we need to short circuit to skip + # path checking at the end of function + if uri.startswith('//') or uri.startswith('http://') or uri.startswith('https://'): + return uri + elif settings.STATIC_URL and uri.startswith(settings.STATIC_URL): path = os.path.join(settings.STATIC_ROOT, uri.replace(settings.STATIC_URL, "")) elif settings.MEDIA_URL and uri.startswith(settings.MEDIA_URL): path = os.path.join(settings.MEDIA_ROOT, uri.replace(settings.MEDIA_URL, ""))