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:
@@ -173,4 +173,46 @@ describe('MentionParser', function () {
|
||||
|
||||
expect($result)->toBe('some text replaced text dewde');
|
||||
});
|
||||
|
||||
describe('urlFriendlyOutput', function () {
|
||||
test('it encodes special characters in values', function () {
|
||||
$content = '<p>Test: <span mention mention-field-id="123">Placeholder</span></p>';
|
||||
$data = [['id' => '123', 'value' => 'Hello & World']];
|
||||
|
||||
$parser = new MentionParser($content, $data);
|
||||
$result = $parser->urlFriendlyOutput()->parse();
|
||||
|
||||
expect($result)->toBe('<p>Test: Hello+%26+World</p>');
|
||||
});
|
||||
|
||||
test('it encodes spaces in values', function () {
|
||||
$content = '<p>Name: <span mention mention-field-id="123">Placeholder</span></p>';
|
||||
$data = [['id' => '123', 'value' => 'John Doe']];
|
||||
|
||||
$parser = new MentionParser($content, $data);
|
||||
$result = $parser->urlFriendlyOutput()->parse();
|
||||
|
||||
expect($result)->toBe('<p>Name: John+Doe</p>');
|
||||
});
|
||||
|
||||
test('it encodes array values', function () {
|
||||
$content = '<p>Tags: <span mention mention-field-id="123">Placeholder</span></p>';
|
||||
$data = [['id' => '123', 'value' => ['Web & Mobile', 'PHP/Laravel']]];
|
||||
|
||||
$parser = new MentionParser($content, $data);
|
||||
$result = $parser->urlFriendlyOutput()->parse();
|
||||
|
||||
expect($result)->toBe('<p>Tags: Web+%26+Mobile,+PHP%2FLaravel</p>');
|
||||
});
|
||||
|
||||
test('it can be disabled explicitly', function () {
|
||||
$content = '<p>Test: <span mention mention-field-id="123">Placeholder</span></p>';
|
||||
$data = [['id' => '123', 'value' => 'Hello & World']];
|
||||
|
||||
$parser = new MentionParser($content, $data);
|
||||
$result = $parser->urlFriendlyOutput(false)->parse();
|
||||
|
||||
expect($result)->toBe('<p>Test: Hello & World</p>');
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user