Index: trunk/extensions/SwiftMedia/wmf/tests/rewriteRegexTest.py |
— | — | @@ -1,19 +1,7 @@ |
2 | 2 | import re |
3 | 3 | |
4 | | -# Rewrite URLs of these forms (source, temp, and thumbnail files): |
5 | | -# (a) http://upload.wikimedia.org/<proj>/<lang>/.* |
6 | | -# => http://msfe/v1/AUTH_<hash>/<proj>-<lang>-local-public/.* |
7 | | -# (b) http://upload.wikimedia.org/<proj>/<lang>/archive/.* |
8 | | -# => http://msfe/v1/AUTH_<hash>/<proj>-<lang>-local-public/archive/.* |
9 | | -# (c) http://upload.wikimedia.org/<proj>/<lang>/thumb/.* |
10 | | -# => http://msfe/v1/AUTH_<hash>/<proj>-<lang>-local-thumb/.* |
11 | | -# (d) http://upload.wikimedia.org/<proj>/<lang>/thumb/archive/.* |
12 | | -# => http://msfe/v1/AUTH_<hash>/<proj>-<lang>-local-thumb/archive/.* |
13 | | -# (e) http://upload.wikimedia.org/<proj>/<lang>/temp/.* |
14 | | -# => http://msfe/v1/AUTH_<hash>/<proj>-<lang>-local-temp/.* |
15 | | - |
16 | 4 | # The regex to test (for rewrite.py) |
17 | | -regex = r'^/(?P<proj>[^/]+)/(?P<lang>[^/]+)/((?P<zone>thumb|temp)/)?(?P<path>(archive/)?[0-9a-f]/(?P<shard>[0-9a-f]{2})/.+)$' |
| 5 | +regex = r'^/(?P<proj>[^/]+)/(?P<lang>[^/]+)/((?P<zone>thumb|temp)/)?(?P<path>((temp|archive)/)?[0-9a-f]/(?P<shard>[0-9a-f]{2})/.+)$' |
18 | 6 | |
19 | 7 | # [url,proj,lang,zone,shard,path] |
20 | 8 | cases = [] |
— | — | @@ -25,6 +13,8 @@ |
26 | 14 | 'wikipedia', 'commons', 'thumb', 'ab', 'a/ab/file.jpg'] ) |
27 | 15 | cases.append( ['/wikipedia/commons/thumb/archive/a/ab/file.jpg', |
28 | 16 | 'wikipedia', 'commons', 'thumb', 'ab', 'archive/a/ab/file.jpg'] ) |
| 17 | +cases.append( ['/wikipedia/commons/thumb/temp/a/ab/file.jpg', |
| 18 | + 'wikipedia', 'commons', 'thumb', 'ab', 'temp/a/ab/file.jpg'] ) |
29 | 19 | cases.append( ['/wikipedia/commons/temp/a/ab/file.jpg', |
30 | 20 | 'wikipedia', 'commons', 'temp', 'ab', 'a/ab/file.jpg'] ) |
31 | 21 | |
Index: trunk/extensions/SwiftMedia/wmf/rewrite.py |
— | — | @@ -191,9 +191,11 @@ |
192 | 192 | # => http://msfe/v1/AUTH_<hash>/<proj>-<lang>-local-thumb/.* |
193 | 193 | # (d) http://upload.wikimedia.org/<proj>/<lang>/thumb/archive/.* |
194 | 194 | # => http://msfe/v1/AUTH_<hash>/<proj>-<lang>-local-thumb/archive/.* |
195 | | - # (e) http://upload.wikimedia.org/<proj>/<lang>/temp/.* |
| 195 | + # (e) http://upload.wikimedia.org/<proj>/<lang>/thumb/temp/.* |
| 196 | + # => http://msfe/v1/AUTH_<hash>/<proj>-<lang>-local-thumb/temp/.* |
| 197 | + # (f) http://upload.wikimedia.org/<proj>/<lang>/temp/.* |
196 | 198 | # => http://msfe/v1/AUTH_<hash>/<proj>-<lang>-local-temp/.* |
197 | | - match = re.match(r'^/(?P<proj>[^/]+)/(?P<lang>[^/]+)/((?P<zone>thumb|temp)/)?(?P<path>(archive/)?[0-9a-f]/(?P<shard>[0-9a-f]{2})/.+)$', req.path) |
| 199 | + match = re.match(r'^/(?P<proj>[^/]+)/(?P<lang>[^/]+)/((?P<zone>thumb|temp)/)?(?P<path>((temp|archive)/)?[0-9a-f]/(?P<shard>[0-9a-f]{2})/.+)$', req.path) |
198 | 200 | if match: |
199 | 201 | # Get the repo zone (if not provided that means "public") |
200 | 202 | zone = (match.group('zone') if match.group('zone') else 'public') |