Skip to content

Improvements to "Short Link to Channel" on user channel settings.

Merge Request Guidelines

  1. Please fill this form out to the best of your ability.
  2. Follow the principle of "One Merge Request, One Concern"
  3. Merge Requests must be complete in total.
  4. Contributed Code must be universal in scope, ie: Able to be used for all installs / install environments.

Description

This patch makes some improvements to the "Short Link to Channel" (AKA "vanityUrl") input field for user channel settings. The patch does the following:

  • Fixes a bug where the "change keydown paste input" event handler for "Short Link to Channel" works for ONLY that of the first channel, if you have multiple channels.
  • Fixes a bug where saving a channel without changing its (non-empty) short-link can cause the short-link to become blank.
  • Sets the maximum length of short-links to 32 characters.
  • Enforces the length and required pattern client-side with "maxlength" and "pattern".
  • Applies some server-side clean-up to "vanityUrl" (truncating to 32 strings, and removing non-alphanumeric characters) for good measure.
  • While applying this patch will not instantly cause overly long short-links to be cleaned, it will guarantee that next time they're saved, they will be in the appropriate format.

Motivation and Context

  • The "change keydown paste input" event handler had to be fixed, for consistent behavior across all "Short Link" inputs.
  • 1024 is way too long as a maximum length for the short link.
  • This ensures client-side enforcement of the maximum length.
  • This ensures sanitization of the short link on server-side, in case it slips by the constraints on client-side.
  • It's not UX-friendly that saving a Channel with an unchanged short-link causes the short-link to clear itself. That's not idempotent.

How Has This Been Tested?

An OSP site made specifically for testing and experimentation was used to test this patch.

  • Clicking on a "Short Link to Channel" label will focus the correct corresponding short-link input.
  • Saving the short link without changing it does not cause it to be saved as blank; it is left unchanged.
  • The "vanityUrlChangeHandler" function works for every user's channels' short-link inputs. Spaces and non-alphanumeric characters cannot be inputted.
  • The "maxlength" attribute works to restrict the input's length to 32 characters max.
  • If an invalid value gets past client-side validation, it will be truncated to 32 characters, then all non-alphanumeric characters will be removed, so the value is in the correct format when saved to the DB.

Screenshots (if appropriate):

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist:

  • My code follows the code style of this project.
  • Merge Request Follows the Merge Request Guidelines
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.

Merge request reports