From 73630eae045549b792c4e3ef77920357f89c6874 Mon Sep 17 00:00:00 2001 From: Michael Merickel Date: Mon, 7 Dec 2015 23:16:26 -0600 Subject: sort by length such that longer paths are tested first --- pyramid/config/views.py | 7 +++++-- 1 file 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)) -- cgit v1.2.3