GUI of regex_redirect does not support targets without a pattern

Created on 30 April 2019, over 5 years ago
Updated 5 September 2024, 3 months ago

The GUI does not support adding redirects to a target without a pattern in the target. The code appears to be able to handle this, but such a redirect must now be added by the API instead of the GUI.

If tried it currently displays the message:

The regex redirect redirect must contain a named capture (value between <> brackets).

Feature request
Status

RTBC

Version

2.0

Component

Code

Created by

🇳🇱Netherlands henrikar

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Merge Requests

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • First commit to issue fork.
  • Assigned to ajits
  • 🇮🇳India ajits India

    I am working on this.

  • Issue was unassigned.
  • Status changed to Needs review 4 months ago
  • 🇮🇳India ajits India

    This is ready for review. The validation of the entered target path is not done by the setRegexErrors function; which feels deliberate.

  • Status changed to Needs work 4 months ago
  • 🇸🇮Slovenia paranojik

    Seems to be working as expected. I'm not sure if a setting for this functionality is actually needed @LaravZ.

    @ajits: You did leave an unused variable in there, though

    diff --git a/src/Form/RegexRedirectForm.php b/src/Form/RegexRedirectForm.php
    index a39041c..fdeb385 100644
    --- a/src/Form/RegexRedirectForm.php
    +++ b/src/Form/RegexRedirectForm.php
    @@ -217,7 +217,6 @@ class RegexRedirectForm extends ContentEntityForm {
         // Set the regex delimiter in code to avoid issues with leading slash.
         $delimiter = '/';
         $source_regex = $delimiter . trim($source_path) . $delimiter;
    -    $redirect_regex = str_replace('internal:', '', $redirect_uri);
     
         if (preg_match($source_regex, '') === FALSE) {
           $form_state->setErrorByName('regex_redirect_source', $this->t('The regex redirect source must be a regex pattern.'));
  • Status changed to Needs review 4 months ago
  • 🇮🇳India ajits India

    Removed unused variable.

  • Status changed to RTBC 3 months ago
  • 🇸🇮Slovenia paranojik

    Looks good now.
    Thanks @ajits.

    Marking RTBC.

Production build 0.71.5 2024