jazzband / django-hosts

Dynamic and static host resolving for Django. Maps hostnames to URLconfs.
http://django-hosts.rtfd.org
Other
979 stars 107 forks source link

Avoid capturing part of parent domain as subdomain #121

Closed x-yzt closed 3 years ago

x-yzt commented 3 years ago

Assuming this configuration:

settings.py

DEFAULT_HOST = 'root'

PARENT_HOST = 'exemple.test'

hosts.py

host_patterns = patterns('',
    host(r'', settings.ROOT_URLCONF, name='root'),
    host(r'other', other.urls, name='other'),
)

This PR will allow, as expected, exemple.test/... to be catched by the root pattern, and other.exemple.test/... by the other pattern.

Currently, the exemple part of exemple.test is stripped out, and host(r'', ...) never matches. This is kind of confusing, because on a dev server where the host is localhost, everything works as expected.

I must admit my solution is not pretty though.

codecov[bot] commented 3 years ago

Codecov Report

Merging #121 (2482a28) into master (f0b8099) will decrease coverage by 0.24%. The diff coverage is 80.00%.

Impacted file tree graph

@@             Coverage Diff             @@
##            master     #121      +/-   ##
===========================================
- Coverage   100.00%   99.75%   -0.25%     
===========================================
  Files           10       11       +1     
  Lines          395      401       +6     
  Branches        59       60       +1     
===========================================
+ Hits           395      400       +5     
- Partials         0        1       +1     
Impacted Files Coverage Δ
django_hosts/middleware.py 97.87% <80.00%> (-2.13%) :arrow_down:
django_hosts/__init__.py 100.00% <0.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more Δ = absolute <relative> (impact), ø = not affected, ? = missing data Powered by Codecov. Last update f0b8099...2482a28. Read the comment docs.