Commit 6a3f882a authored by Damien McKenna's avatar Damien McKenna Committed by Sascha Grossenbacher
Browse files

Issue #3127562 by DamienMcKenna: Document why the domain redirect "host" value is converted

parent 427ea275
Loading
Loading
Loading
Loading
+9 −2
Original line number Diff line number Diff line
@@ -80,9 +80,16 @@ class DomainRedirectRequestSubscriber implements EventSubscriberInterface {
      $protocol = $request->getScheme() . '://';
      $destination = NULL;

      // Prior to being saved the source domain value has any periods replaced
      // with a colon, which makes it suitable for use as a key. In order to
      // match against those values the current hostname must be similarly
      // converted.
      // @see \Drupal\redirect_domain\Form\RedirectDomainForm::submitForm()
      $converted_host = str_replace('.', ':', $host);

      // Checks if there is a redirect domain in the configuration.
      if (isset($domains[str_replace('.', ':', $host)])) {
        foreach ($domains[str_replace('.', ':', $host)] as $item) {
      if (isset($domains[$converted_host])) {
        foreach ($domains[$converted_host] as $item) {
          if ($this->pathMatcher->matchPath($path, $item['sub_path'])) {
            $destination = $item['destination'];
            break;
+1 −0
Original line number Diff line number Diff line
@@ -150,6 +150,7 @@ class RedirectDomainForm extends ConfigFormBase {
      foreach ($redirects as $redirect) {
        if (!empty($redirect['from']) && !empty($redirect['destination'])) {
          // Replace '.' with ':' for an eligible key.
          // @see \Drupal\redirect_domain\EventSubscriber\DomainRedirectRequestSubscriber::onKernelRequestCheckDomainRedirect()
          $redirect['from'] = str_replace('.', ':', $redirect['from']);
          $domain_redirects[$redirect['from']][] = [
            'sub_path' => '/' . ltrim($redirect['sub_path'], '/'),