django-sonar icon indicating copy to clipboard operation
django-sonar copied to clipboard

Feature request: exclude also i18n URLs

Open eriktelepovsky opened this issue 10 months ago • 2 comments

Hello.

It would be great if DJANGO_SONAR['excludes'] could automatically detect language code prefix in the URL path. So instead of setting this:

DJANGO_SONAR = {
    'excludes': [
        '/en/jsi18n/', '/sk/jsi18n/', '/cs/jsi18n/', '/pl/jsi18n/', '/hu/jsi18n/', '/uk/jsi18n/',
    ],
}

it would be able to use a using single path instead:

DJANGO_SONAR = {
    'excludes': [
        '/jsi18n/',
    ],
}

The jsi18n path is defined in urls.py using i18n patterns:

urlpatterns += i18n_patterns(
    path('jsi18n/', JavaScriptCatalog.as_view(), name='javascript-catalog'),
)

Thanks!

eriktelepovsky avatar Apr 19 '24 18:04 eriktelepovsky

Hello again.

Thanks for all these suggestions man.

I think the best way to solve these kind of issues is to support regex on the "excludes" parameter. In that way one could do something like this:

DJANGO_SONAR = {
    'excludes': [
        '/admin/',  # Treated as literal string
        '/__reload__/',  # Treated as literal string
        r'^/[a-z]{2}/jsi18n/',  # Treated as regex pattern
    ],
}

I'll look into it for a future release.

metalogico avatar Apr 20 '24 09:04 metalogico

Yes, that's exactly what I meant :) Thank you! Looking forward to it.

eriktelepovsky avatar Apr 24 '24 12:04 eriktelepovsky