ABDALLALSWAITI commited on
Commit
ab6db64
·
verified ·
1 Parent(s): 69a76c1

Update api.py

Browse files
Files changed (1) hide show
  1. api.py +4 -4
api.py CHANGED
@@ -60,7 +60,7 @@ def process_html_with_images(html_content: str, temp_dir: str, image_mapping: di
60
  # Replace various image reference patterns
61
  # Pattern 1: src="filename"
62
  html_content = re.sub(
63
- f'src=["\'](?:\.\/)?{re.escape(original_name)}["\']',
64
  f'src="{file_url}"',
65
  html_content,
66
  flags=re.IGNORECASE
@@ -68,7 +68,7 @@ def process_html_with_images(html_content: str, temp_dir: str, image_mapping: di
68
 
69
  # Pattern 2: src='filename'
70
  html_content = re.sub(
71
- f"src=['\"](?:\.\/)?{re.escape(original_name)}['\"]",
72
  f'src="{file_url}"',
73
  html_content,
74
  flags=re.IGNORECASE
@@ -76,7 +76,7 @@ def process_html_with_images(html_content: str, temp_dir: str, image_mapping: di
76
 
77
  # Pattern 3: background-image: url(filename)
78
  html_content = re.sub(
79
- f'url\(["\']?(?:\.\/)?{re.escape(original_name)}["\']?\)',
80
  f'url("{file_url}")',
81
  html_content,
82
  flags=re.IGNORECASE
@@ -84,7 +84,7 @@ def process_html_with_images(html_content: str, temp_dir: str, image_mapping: di
84
 
85
  # Pattern 4: href for links
86
  html_content = re.sub(
87
- f'href=["\'](?:\.\/)?{re.escape(original_name)}["\']',
88
  f'href="{file_url}"',
89
  html_content,
90
  flags=re.IGNORECASE
 
60
  # Replace various image reference patterns
61
  # Pattern 1: src="filename"
62
  html_content = re.sub(
63
+ rf'src=["\'](?:\./)?{re.escape(original_name)}["\']',
64
  f'src="{file_url}"',
65
  html_content,
66
  flags=re.IGNORECASE
 
68
 
69
  # Pattern 2: src='filename'
70
  html_content = re.sub(
71
+ rf"src=['\"](?:\./)?{re.escape(original_name)}['\"]",
72
  f'src="{file_url}"',
73
  html_content,
74
  flags=re.IGNORECASE
 
76
 
77
  # Pattern 3: background-image: url(filename)
78
  html_content = re.sub(
79
+ rf'url\(["\']?(?:\./)?{re.escape(original_name)}["\']?\)',
80
  f'url("{file_url}")',
81
  html_content,
82
  flags=re.IGNORECASE
 
84
 
85
  # Pattern 4: href for links
86
  html_content = re.sub(
87
+ rf'href=["\'](?:\./)?{re.escape(original_name)}["\']',
88
  f'href="{file_url}"',
89
  html_content,
90
  flags=re.IGNORECASE