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

Command icon 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:

Comments

yannickoo created an issue. See original summary.

yannickoo’s picture

Issue summary: View changes

yannickoo’s picture

Status: Active » Needs review
smustgrave’s picture

Status: Needs review » Needs work

May need a test to show this bug and make sure it doesn't come back

sd9121’s picture

Assigned: Unassigned » sd9121
sd9121’s picture

Assigned: sd9121 » Unassigned
Status: Needs work » Needs review
sd9121’s picture

Assigned: Unassigned » sd9121

mogtofu33 made their first commit to this issue’s fork.

sd9121’s picture

Assigned: sd9121 » Unassigned
smustgrave’s picture

Status: Needs review » Needs work

So open threads on the MR.

mogtofu33’s picture

Status: Needs work » Needs review

PHPUnit attributes updated.

smustgrave’s picture

Status: Needs review » Needs work

Thanks! Appears to have pipeline issues

mogtofu33’s picture

Status: Needs work » Needs review

Fixed missing @group. Unrelated func test StatusTest failing.

smustgrave’s picture

Can confirm the StatusTest failure as I'm seeing it on another MR.

smustgrave’s picture

Status: Needs review » Reviewed & tested by the community

Feedback on this one appears to be addressed.

nod_ made their first commit to this issue’s fork.

  • nod_ committed 08bc5ec4 on 11.2.x
    Issue #3522474 by yannickoo, smustgrave, sd9121, mogtofu33, nod_: Fix...

  • nod_ committed f01ae18d on 11.x
    Issue #3522474 by yannickoo, smustgrave, sd9121, mogtofu33, nod_: Fix...
nod_’s picture

Version: 11.x-dev » 11.2.x-dev
Status: Reviewed & tested by the community » Fixed

Committed and pushed f01ae18dfdb to 11.x and 08bc5ec4746 to 11.2.x. Thanks!

Now that this issue is closed, please review the contribution record.

As a contributor, attribute any organization helped you, or if you volunteered your own time.

Maintainers, please credit people who helped resolve this issue.

yannickoo’s picture

Oh wow, so nice to see that this was committed <3 Thank you very much 💪

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.

yannickoo’s picture

I 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