diff options
| author | Michael Merickel <michael@merickel.org> | 2015-12-07 23:16:26 -0600 |
|---|---|---|
| committer | Michael Merickel <michael@merickel.org> | 2015-12-07 23:16:26 -0600 |
| commit | 73630eae045549b792c4e3ef77920357f89c6874 (patch) | |
| tree | 2557a6527228ee3c10ee761bfc8b150407b5e0e7 | |
| parent | d0bd5fb326d8999e3a40e6e2d121aa69cfe05476 (diff) | |
| download | pyramid-73630eae045549b792c4e3ef77920357f89c6874.tar.gz pyramid-73630eae045549b792c4e3ef77920357f89c6874.tar.bz2 pyramid-73630eae045549b792c4e3ef77920357f89c6874.zip | |
sort by length such that longer paths are tested first
| -rw-r--r-- | pyramid/config/views.py | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/pyramid/config/views.py b/pyramid/config/views.py index f496dfb7d..16b150a9e 100644 --- a/pyramid/config/views.py +++ b/pyramid/config/views.py @@ -1,3 +1,4 @@ +import bisect import inspect import posixpath import operator @@ -2102,7 +2103,9 @@ class StaticURLInfo(object): idx = specs.index(spec) cache_busters.pop(idx) - cache_busters.insert(0, (spec, cachebust)) + lengths = [len(t[0]) for t in cache_busters] + new_idx = bisect.bisect_left(lengths, len(spec)) + cache_busters.insert(new_idx, (spec, cachebust)) intr = config.introspectable('cache busters', spec, @@ -2126,7 +2129,7 @@ class StaticURLInfo(object): rawspec = '{0}:{1}'.format(source.pkg_name, rawspec) break - for base_spec, cachebust in self.cache_busters: + for base_spec, cachebust in reversed(self.cache_busters): if ( base_spec == rawspec or (base_spec.endswith('/') and rawspec.startswith(base_spec)) |
