2018-03-08 09:37:09 +01:00
|
|
|
import re
|
2020-07-07 01:26:50 +02:00
|
|
|
from typing import Tuple
|
2017-11-09 16:31:57 +01:00
|
|
|
|
|
|
|
THUMBOR_EXTERNAL_TYPE = 'external'
|
|
|
|
THUMBOR_S3_TYPE = 's3'
|
|
|
|
THUMBOR_LOCAL_FILE_TYPE = 'local_file'
|
|
|
|
|
2021-02-12 08:19:30 +01:00
|
|
|
|
2020-07-07 01:26:50 +02:00
|
|
|
def separate_url_and_source_type(url: str) -> Tuple[str, str]:
|
2018-03-08 09:37:09 +01:00
|
|
|
THUMBNAIL_URL_PATT = re.compile('^(?P<actual_url>.+)/source_type/(?P<source_type>.+)')
|
|
|
|
matches = THUMBNAIL_URL_PATT.match(url)
|
2020-07-05 03:00:50 +02:00
|
|
|
assert matches is not None
|
2018-03-08 09:37:09 +01:00
|
|
|
return (matches.group('source_type'), matches.group('actual_url'))
|