Quantcast
Channel: Issues for Drupal core
Viewing all articles
Browse latest Browse all 305144

Merge two regex in one to define version number

$
0
0

Problem/Motivation

Two regex could be merged in one in locale_translation_build_projects().

      if (preg_match("/^(\d+\.x-\d+\.).*$/", $data['info']['version'], $matches)) {
        // Example matches: 8.x-1.x-dev, 8.x-1.0-alpha1+5-dev => 8.x-1.x
        $data['info']['version'] = $matches[1] . 'x';
      }
      elseif (preg_match("/^(\d+\.\d+\.).*$/", $data['info']['version'], $matches)) {
        // Example match: 8.0.0-dev => 8.0.x (Drupal core)
        $data['info']['version'] = $matches[1] . 'x';
      }

Minor but remove 3 lines of code.

Proposed resolution

Merge regex in one.

      if (preg_match("/^(\d+\.(x-)?\d+\.).*$/", $data['info']['version'], $matches)) {
        // Example matches:
        // * 8.x-1.x-dev, 8.x-1.0-alpha1+5-dev => 8.x-1.x
        // * 8.0.0-dev => 8.0.x (Drupal core)
        $data['info']['version'] = $matches[1] . 'x';
      }

Viewing all articles
Browse latest Browse all 305144

Latest Images

Trending Articles



Latest Images

<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>