torchbox / django-pattern-library

UI pattern libraries for Django templates
https://torchbox.github.io/django-pattern-library/
BSD 3-Clause "New" or "Revised" License
360 stars 44 forks source link

library doesn't handle windows paths #222

Closed reedjones closed 1 year ago

reedjones commented 1 year ago

Found a bug? Please fill out the sections below. 👍

The url regex doesn't account for windows paths that have '\\'

A summary of the issue.

Steps to Reproduce

clone the main repo, run the server, and you will get a PatternLibraryEmpty error because it can't find the paths because patterns/atoms won't work on windows

so now we have to change our settings for windows style path

PATTERN_LIBRARY = {
#...
    "SECTIONS": [
        ("atoms", ["patterns\\atoms"]),  # was patterns/atoms 
        ("molecules", ["patterns\\molecules"]), # etc... 
        ("pages", ["patterns\\pages"]),
    ],
}

Now you will get an error about the url not matching because the url also doesn't handle windows paths

basically this r"^pattern/(?P<pattern_template_name>[\w./-]+%s)$" should be r"^pattern/(?P<pattern_template_name>[\w./-\\]+%s)$"