Skip to content

False positives when matching theme based on handle #1710

@BrunoRoemers

Description

@BrunoRoemers

Describe the bug
DSpace 7 has the ability to switch themes based on the handle of the current item/collection/community (or the handle of one of their parents). Whether a theme is a match, is ultimately decided here, however this logic contains a bug.

Example: given dso.handle = http://hdl.handle.net/123456789/123123 and theme.config.handle = 123456789/123, the theme should not be matched, but it will be matched because: http://hdl.handle.net/123456789/123123.

To Reproduce
Steps to reproduce the behavior:

  1. configure a theme that matches on a handle, e.g. 123456789/123
  2. create an item and edit the handle such that it equals the theme handle + something extra, e.g. 123456789/123123
  3. visit the item and observe that the theme is active
    • you can inspect the Redux state with this extension to see which theme is active (theme.currentTheme, action of type dspace/theme/set has been dispatched here)

Expected behavior
The theme should NOT be active, because the theme handle does not match the item handle.

Suggestion
Add a utility function that given any string, returns a handle (in some canonical format) or undefined (if the input string could not be parsed). This function would become the single source of truth of what constitutes a valid handle.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions