Enhance redirect URL handling and MentionParser functionality (#639)
- Updated the `redirect_url` validation in `UserFormRequest` to accept strings instead of just max length. - Modified `MentionParser` to include a `urlFriendlyOutput` method, allowing for URL encoding of special characters in parsed values. - Adjusted the `PublicFormController` to utilize the new `urlFriendlyOutput` method for redirect URLs. - Created a migration to change the `redirect_url` field type in the database from string to text, accommodating longer URLs. - Added tests to ensure proper handling of long redirect URLs and the functionality of the new URL-friendly output feature in `MentionParser`. This update improves the flexibility and robustness of form handling and URL processing.
This commit is contained in:
29
api/tests/Feature/Forms/RedirectUrlLengthTest.php
Normal file
29
api/tests/Feature/Forms/RedirectUrlLengthTest.php
Normal file
@@ -0,0 +1,29 @@
|
||||
<?php
|
||||
|
||||
test('form accepts long redirect urls', function () {
|
||||
$this->withoutExceptionHandling();
|
||||
$user = $this->actingAsUser();
|
||||
$workspace = $this->createUserWorkspace($user);
|
||||
$form = $this->createForm($user, $workspace);
|
||||
|
||||
// Create a very long URL (more than 255 characters)
|
||||
$longUrl = 'https://example.com/?' . str_repeat('very-long-parameter=value&', 50);
|
||||
|
||||
$this->putJson(route('open.forms.update', $form->id), array_merge($form->toArray(), [
|
||||
'redirect_url' => $longUrl
|
||||
]))->assertStatus(200);
|
||||
|
||||
expect($form->fresh()->redirect_url)->toBe($longUrl);
|
||||
});
|
||||
|
||||
test('form accepts null redirect url', function () {
|
||||
$user = $this->actingAsUser();
|
||||
$workspace = $this->createUserWorkspace($user);
|
||||
$form = $this->createForm($user, $workspace);
|
||||
|
||||
$this->putJson(route('open.forms.update', $form->id), array_merge($form->toArray(), [
|
||||
'redirect_url' => null
|
||||
]))->assertStatus(200);
|
||||
|
||||
expect($form->fresh()->redirect_url)->toBeNull();
|
||||
});
|
||||
Reference in New Issue
Block a user