Tonight
This commit is contained in:
parent
28323f145e
commit
94f9c0d594
76 changed files with 3238 additions and 1230 deletions
|
|
@ -19,7 +19,7 @@ export class ScreenshotCache {
|
|||
* Build a cache key by quantizing view params and hashing.
|
||||
* - lat/lon quantized to 2 decimal places
|
||||
* - zoom quantized to integer
|
||||
* - filters and POI categories sorted alphabetically
|
||||
* - filters, configurable filters, and POI categories sorted alphabetically
|
||||
*/
|
||||
buildKey(params: URLSearchParams): string {
|
||||
const normalized: Record<string, string> = {};
|
||||
|
|
@ -40,6 +40,16 @@ export class ScreenshotCache {
|
|||
normalized.filters = filters.join(',');
|
||||
}
|
||||
|
||||
const schools = params.getAll('school').sort();
|
||||
if (schools.length > 0) {
|
||||
normalized.school = schools.join(',');
|
||||
}
|
||||
|
||||
const crimes = params.getAll('crime').sort();
|
||||
if (crimes.length > 0) {
|
||||
normalized.crime = crimes.join(',');
|
||||
}
|
||||
|
||||
// Sort POI categories
|
||||
const pois = params.getAll('poi').sort();
|
||||
if (pois.length > 0) {
|
||||
|
|
|
|||
|
|
@ -12,6 +12,8 @@ test('buildScreenshotRequest accepts supported screenshot parameters', () => {
|
|||
og: '1',
|
||||
path: '/invite/abc123',
|
||||
filter: ['Last known price:100000:500000', 'Total floor area (sqm):50:150'],
|
||||
school: 'primary:good:2:1:10',
|
||||
crime: ['Burglary (avg/yr):0:5', 'Vehicle crime (avg/yr):0:10'],
|
||||
poi: 'supermarket',
|
||||
tt: 'transit:kings-cross:Kings Cross:b:0:30',
|
||||
});
|
||||
|
|
@ -25,6 +27,11 @@ test('buildScreenshotRequest accepts supported screenshot parameters', () => {
|
|||
'Last known price:100000:500000',
|
||||
'Total floor area (sqm):50:150',
|
||||
]);
|
||||
assert.deepEqual(result.qs.getAll('school'), ['primary:good:2:1:10']);
|
||||
assert.deepEqual(result.qs.getAll('crime'), [
|
||||
'Burglary (avg/yr):0:5',
|
||||
'Vehicle crime (avg/yr):0:10',
|
||||
]);
|
||||
});
|
||||
|
||||
test('buildScreenshotRequest rejects invalid numeric values', () => {
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@ const MAX_VALUE_LENGTH = 500;
|
|||
const NUMERIC_RE = /^-?(?:\d+|\d*\.\d+)$/;
|
||||
const PATH_RE = /^\/(?:invite\/[A-Za-z0-9]{1,20})?$/;
|
||||
const SAFE_VALUE_RE = /^[^\u0000-\u001f\u007f]+$/;
|
||||
const REPEATED_KEYS = ['filter', 'poi', 'tt'] as const;
|
||||
const REPEATED_KEYS = ['filter', 'school', 'crime', 'poi', 'tt'] as const;
|
||||
|
||||
type Query = Record<string, unknown>;
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue