accessibility-exchange / platform

The Accessibility Exchange platform.
https://github.com/orgs/accessibility-exchange/projects/2/views/8
BSD 3-Clause "New" or "Revised" License
4 stars 10 forks source link

Entering an organization's website URL throws an error if the URL scheme isn't included. #2170

Closed jobara closed 5 months ago

jobara commented 5 months ago

Prerequisites

Describe the bug

When creating the public page for an organization you can enter in the org's website link. The description says "Website links must be in the format “https://example.com”, or “example.com”. " However, entering example.com throws the error "The Website link is not a valid URL.". Adding the scheme (e.g. https://) before will resolve the error.

To Reproduce

Steps to reproduce the behavior:

  1. Log in as a community organization
  2. Create/edit the public page
  3. On the about page, enter the website link as "example.com"
  4. Notice the error "The Website link is not a valid URL."

Expected behavior

Either the URL without the scheme should be accepted, or the instructions updated to not mention this as an acceptable format.

Screenshots

Screenshot showing URL validation error when no scheme provided Screenshot showing field passes validation when scheme provided
jobara commented 5 months ago

We're using Laravel's active_url validation rule. It will pass the inputted URL through PHP's parse_url function, with the component set to PHP_URL_HOST. (See: https://github.com/laravel/framework/blob/fc7b8f6984c58265d1fe111dafa124f9620db767/src/Illuminate/Validation/Concerns/ValidatesAttributes.php#L125 ). However, as noted in the php docs, if the scheme is omitted the url is returned as the 'path' value. The result is that the host is empty and active_url is getting a null value returned from parse_url and as such, fails validation.

The simple solution would be to require the scheme be provided.