Skip to content

Templates with a dash "-" in the path are no longer resolved #229

Closed
@migonzalvar

Description

@migonzalvar

Issue Summary

I think I found a regression. After #223, templates with a dash "-" in the path are no longer resolved.

Steps to Reproduce

  1. Add a pattern with a dash, for example, patterns/components/quote-block/quote-block.html
  2. Navigate to http://localhost:8000/pattern-library/
  3. An error is shown: Reverse for 'display_pattern' with arguments '('patterns/components/quote-block/quote-block.html',)' not found. 1 pattern(s) tried: ['\\-/pattern\\-library/pattern/(?P<pattern_template_name>[\\w./-\\\\]+.html)$']

In version 1.0.0 it works just fine.

Technical details

In this snippet, I prove that the previous and current regexp does not behave the same with respect to dashes.

import re
template = "pattern/my-component.html"
previous = r"^pattern/(?P<pattern_template_name>[\w./-]+.html)$"
current = r"^pattern/(?P<pattern_template_name>[\w./-\\]+.html)$"
print("1.0.0", re.match(previous, template))
print("1.0.1", re.match(current, template))
$ python poc.py 
1.0.0 <re.Match object; span=(0, 25), match='pattern/my-component.html'>
1.0.1 None

Versions:

  • Python 3.8.10
  • Django 3.2.20

PS: Thank you for this awesome library.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions