Fix RegEx for Icon library schema definition

Created on 2 May 2025, 8 days ago

Problem/Motivation

When trying to load a library with an icon pack it seems like the regular expression for the library property schema definition is not correct and does not allow hyphens which are valid in THEME.libraries.yml.

An IconPackConfigErrorException exception is being thrown:

Drupal\Core\Theme\Icon\Exception\IconPackConfigErrorException: my_theme:foo Error in definition `foo`:[library] Does not match the regex pattern ^\w+/[A-Za-z]+\w*$ in Drupal\Core\Theme\Icon\Plugin\IconPackManager->validateDefinition() (line 430 of core/lib/Drupal/Core/Theme/Icon/Plugin/IconPackManager.php).

Steps to reproduce

Create a new THEME.icons.yml file in your theme and try to use - in the library property:

foo:
  label: Foo
  extractor: path
  config:
    sources:
      - images/svgs/*.svg
  library: 'my_theme/an-icon-library'

Proposed resolution

The ">regular expression for validating the library should be changed from ^\w+/[A-Za-z]+\w*$ to ^[a-zA-Z0-9_-]+\/[a-zA-Z0-9_-]+$ (following the RegEx from metadata.schema.json which ensures we can use hyphens in the library name after the slash.

πŸ› Bug report
Status

Active

Version

11.0 πŸ”₯

Component

CSS

Created by

πŸ‡©πŸ‡ͺGermany yannickoo Berlin

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

Merge Requests

Comments & Activities

Production build 0.71.5 2024