Skip to content

Commit

Permalink
Fix redirect URL mentions (#707)
Browse files Browse the repository at this point in the history
  • Loading branch information
chiragchhatrala authored Feb 24, 2025
1 parent d190211 commit 65eebb7
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 9 deletions.
6 changes: 5 additions & 1 deletion api/app/Service/Forms/FormSubmissionProcessor.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,12 @@ private function isFieldUsedInRedirectUrl(Form $form, string $fieldId): bool
*/
public function getRedirectData(Form $form, array $submissionData): array
{
$formattedData = collect($submissionData)->map(function ($value, $key) {
return ['id' => $key, 'value' => $value];
})->values()->all();

$redirectUrl = ($form->redirect_url)
? (new MentionParser($form->redirect_url, array_values($submissionData)))->urlFriendlyOutput()->parseAsText()
? (new MentionParser($form->redirect_url, $formattedData))->urlFriendlyOutput()->parseAsText()
: null;

if ($redirectUrl && !filter_var($redirectUrl, FILTER_VALIDATE_URL)) {
Expand Down
10 changes: 2 additions & 8 deletions api/tests/Feature/Forms/FormSubmissionProcessorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -121,10 +121,7 @@

$processor = new FormSubmissionProcessor();
$redirectData = $processor->getRedirectData($form, [
'field_1' => [
'id' => 'field_1',
'value' => 'test-value'
]
'field_1' => 'test-value'
]);

expect($redirectData)->toBe([
Expand All @@ -142,10 +139,7 @@

$processor = new FormSubmissionProcessor();
$redirectData = $processor->getRedirectData($form, [
'field_1' => [
'id' => 'field_1',
'value' => 'test-value'
]
'field_1' => 'test-value'
]);

expect($redirectData)->toBe([
Expand Down

0 comments on commit 65eebb7

Please sign in to comment.