Skip to content

Commit f5e9031

Browse files
committed
fix(markdown): correctly rewrite relative src and srcset URLs to absolute
1 parent 1ac70c8 commit f5e9031

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

app/Support/Markdown.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -114,9 +114,9 @@ protected function convertSpecialBlockquotes(): static
114114
public function absoluteImageUrls(string $baseUrl): static
115115
{
116116
$this->content = preg_replace(
117-
pattern: '/src=["\'](?!https?:\/\/)([^"\']+)["\'][^>]/i',
118-
replacement: 'src="' . $baseUrl . '$1" ',
119-
subject: $this->content
117+
'/\b(src|srcset)\s*=\s*(["\'])(?!https?:\/\/|data:|\/\/)([^"\']+)\2/i',
118+
'$1=$2' . $baseUrl . '$3$2',
119+
$this->content
120120
);
121121

122122
return $this;

0 commit comments

Comments
 (0)