Skip to content

Commit

Permalink
Merge pull request #117 from canyongbs/bugfix/AIDAPP-123-part-2
Browse files Browse the repository at this point in the history
[AIDAPP-123]: Better match the path the check for file existence
  • Loading branch information
Orrison authored Jun 7, 2024
2 parents ffe1106 + e418a3c commit 8f04c2b
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion app/Support/MediaEncoding/TiptapMediaEncoder.php
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,21 @@ public static function encodeContent(string $content, string $disk): string

$defaultDirectory = config('filament-tiptap-editor.directory');

if (! Storage::disk($disk)->exists(ltrim($path, config('filesystems.disks.s3.root'))) && Str::isUrl($content)) {
$root = preg_quote(config('filesystems.disks.s3.root'), '/');

$regexMatch = preg_match(
pattern: "/\/?{$root}\/?(.+)/",
subject: $path,
matches: $matches,
flags: PREG_OFFSET_CAPTURE,
offset: 0
);

if (
$regexMatch === 1
&& ! Storage::disk($disk)->exists($matches[1][0])
&& Str::isUrl($content)
) {
return $content;
}

Expand Down

0 comments on commit 8f04c2b

Please sign in to comment.