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.
Issue fork drupal-3522474
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
- 3522474-fix-regex-for
changes, plain diff MR !12026
Comments
Comment #2
yannickooComment #4
yannickooComment #5
smustgrave commentedMay need a test to show this bug and make sure it doesn't come back
Comment #6
sd9121 commentedComment #7
sd9121 commentedComment #8
sd9121 commentedComment #10
sd9121 commentedComment #11
smustgrave commentedSo open threads on the MR.
Comment #12
mogtofu33 commentedPHPUnit attributes updated.
Comment #13
smustgrave commentedThanks! Appears to have pipeline issues
Comment #14
mogtofu33 commentedFixed missing @group. Unrelated func test StatusTest failing.
Comment #15
smustgrave commentedCan confirm the StatusTest failure as I'm seeing it on another MR.
Comment #16
smustgrave commentedFeedback on this one appears to be addressed.
Comment #21
nod_Committed and pushed f01ae18dfdb to 11.x and 08bc5ec4746 to 11.2.x. Thanks!
Comment #23
yannickooOh wow, so nice to see that this was committed <3 Thank you very much 💪
Comment #25
yannickooI had to create a follow-up issue since we are not allowing dots to be used in the library name which is needed when you want to load a SDC library ➡️ #3549146: Fix RegEx for Icon library schema definition