Skip to content

Commit

Permalink
bugfix: Modify regular rules
Browse files Browse the repository at this point in the history
  • Loading branch information
meua committed Jan 4, 2024
1 parent fadfb2d commit 397b535
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions apps/challenges/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import random
import string
import uuid
import re

from botocore.exceptions import ClientError
from django.conf import settings
Expand Down Expand Up @@ -628,10 +629,10 @@ def add_sponsors_to_challenge(yaml_file_data, challenge):


def simple_image_url(image_url) -> str:
prefix = settings.MEDIA_URL
if prefix in image_url:
index = image_url.index(prefix) + len(prefix)
new_url = image_url[index:]
pattern = r".*\/media\/(?!.*\/media\/)"
match = re.search(pattern, image_url)
if match:
return image_url[match.end():]
else:
new_url = image_url
return new_url
return image_url

0 comments on commit 397b535

Please sign in to comment.