From d6816df6f65fb6658c629f6db69f6c2f54a723ef Mon Sep 17 00:00:00 2001 From: Punyapal Shah Date: Sun, 3 Nov 2024 23:39:10 +0530 Subject: [PATCH 1/3] feat: update link rendering to use anchor tags for improved styling and functionality --- .../ParsableContentProviders/LinkProviderParsable.php | 6 ++++-- .../Services/ContentTest/it_ignores_mention_inside__a_.snap | 3 ++- .../only_links_with_images_or_html_oEmbeds_are_parsed.snap | 3 ++- 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/app/Services/ParsableContentProviders/LinkProviderParsable.php b/app/Services/ParsableContentProviders/LinkProviderParsable.php index 8764ca1a..636cca3d 100644 --- a/app/Services/ParsableContentProviders/LinkProviderParsable.php +++ b/app/Services/ParsableContentProviders/LinkProviderParsable.php @@ -38,6 +38,8 @@ function (array $matches): string { $url = $isMail ? 'mailto:'.$humanUrl : $url; + $linkHtml = ''.$humanUrl.''; + if (! $isMail && $url) { $service = new MetaData($url); $metadata = $service->fetch(); @@ -50,11 +52,11 @@ function (array $matches): string { ])->render() ); - return (string) preg_replace('//', '', $trimmed); + return $linkHtml.' '.preg_replace('//', '', $trimmed); } } - return ''.$humanUrl.''; + return $linkHtml; }, str_replace('&', '&', $content) ); diff --git a/tests/.pest/snapshots/Unit/Services/ContentTest/it_ignores_mention_inside__a_.snap b/tests/.pest/snapshots/Unit/Services/ContentTest/it_ignores_mention_inside__a_.snap index da4493f8..22b0737a 100644 --- a/tests/.pest/snapshots/Unit/Services/ContentTest/it_ignores_mention_inside__a_.snap +++ b/tests/.pest/snapshots/Unit/Services/ContentTest/it_ignores_mention_inside__a_.snap @@ -1,4 +1,4 @@ -
pinkary.com/@nunomaduro +
\ No newline at end of file diff --git a/tests/.pest/snapshots/Unit/Services/ContentTest/only_links_with_images_or_html_oEmbeds_are_parsed.snap b/tests/.pest/snapshots/Unit/Services/ContentTest/only_links_with_images_or_html_oEmbeds_are_parsed.snap index 53288375..45d0d35f 100644 --- a/tests/.pest/snapshots/Unit/Services/ContentTest/only_links_with_images_or_html_oEmbeds_are_parsed.snap +++ b/tests/.pest/snapshots/Unit/Services/ContentTest/only_links_with_images_or_html_oEmbeds_are_parsed.snap @@ -1,4 +1,4 @@ -Sure, here is the link:
laravel.com +
. Let me know if you have any questions. \ No newline at end of file From 9b2ad55f29f116709348a4f5b896f986fdd5f0b9 Mon Sep 17 00:00:00 2001 From: Punyapal Shah Date: Sun, 3 Nov 2024 23:39:13 +0530 Subject: [PATCH 2/3] refactor: remove unnecessary phpstan ignore comment in search method --- app/Services/Autocomplete/Types/Mentions.php | 1 - 1 file changed, 1 deletion(-) diff --git a/app/Services/Autocomplete/Types/Mentions.php b/app/Services/Autocomplete/Types/Mentions.php index 5bb00090..c949e552 100644 --- a/app/Services/Autocomplete/Types/Mentions.php +++ b/app/Services/Autocomplete/Types/Mentions.php @@ -36,7 +36,6 @@ public function matchExpression(): string */ public function search(?string $query): Collection { - // @phpstan-ignore-next-line return Collection::make( User::query() ->when(auth()->id(), fn (Builder $constraint, string|int $id) => $constraint->whereKeyNot($id)) From 67f9a3491816dc2a59f5fb6bf75baa1294fd5a12 Mon Sep 17 00:00:00 2001 From: Punyapal Shah Date: Sun, 3 Nov 2024 23:42:21 +0530 Subject: [PATCH 3/3] fix: remove phpstan ignore comment for new hashtags creation logic --- app/EventActions/UpdateQuestionHashtags.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/EventActions/UpdateQuestionHashtags.php b/app/EventActions/UpdateQuestionHashtags.php index 49ca4306..ba17551e 100644 --- a/app/EventActions/UpdateQuestionHashtags.php +++ b/app/EventActions/UpdateQuestionHashtags.php @@ -29,7 +29,7 @@ public function handle(): array $existingHashtags = Hashtag::query()->whereIn('name', $parsedHashtags->all())->get(); - $newHashtags = $parsedHashtags->diff($existingHashtags->pluck('name')) + $newHashtags = $parsedHashtags->diff($existingHashtags->pluck('name')) // @phpstan-ignore-line ->map(fn (string $name): Hashtag => Hashtag::query()->create(['name' => $name])); return $this->question->hashtags()->sync($existingHashtags->merge($newHashtags));