Include the SVG normalizer build in renderer cache keys so a normalizer upgrade cannot serve stale canonical SVG output.
- commit
- 3f5a2986dea6329a47f2dbed6be578579ceed21d
- parent
- 482971b8151308f04d9c285d566f450b69974e33
- author
- Dami <dami.etoile@gmail.com>
| M | renderers/ | 4 | ++-- |
| M | renderers/ | 4 | ++-- |
@@ -2,7 +2,7 @@ import { RenderError, RequestError } from './errors'
22 import { canonicalizeSvg } from './svg'33 import type { EngineId, RendererAdapter, RenderRequest } from './types'44 import { parseUnitRenderRequest } from './validation'5-import { normalizationFor } from '../../../../shared/svg/index.js'5+import { NORMALIZER_BUILD, normalizationFor } from '../../../../shared/svg/index.js'66 77 const CACHE_MAX_AGE = 1_80088 const CACHE_SCHEMA = '2'@@ -59,7 +59,7 @@ function base64Url(bytes: Uint8Array): string {
5959 6060 async function cacheRequestFor(request: RenderRequest, build: string): Promise<Request> {6161 const digest = await crypto.subtle.digest('SHA-256', new TextEncoder().encode(canonicalRequest(request)))62- return new Request(`https://diagramzip-unit-cache.invalid/${CACHE_SCHEMA}/${encodeURIComponent(request.engine)}/${encodeURIComponent(build)}/${base64Url(new Uint8Array(digest))}`)62+ return new Request(`https://diagramzip-unit-cache.invalid/${CACHE_SCHEMA}/${encodeURIComponent(NORMALIZER_BUILD)}/${encodeURIComponent(request.engine)}/${encodeURIComponent(build)}/${base64Url(new Uint8Array(digest))}`)6363 }6464 6565 function responseWithCacheStatus(response: Response, status: 'HIT' | 'MISS'): Response {@@ -1,4 +1,4 @@
1-import { canonicalizeSvg, SvgNormalizationError, normalizationFor } from '../../shared/svg/index.js'1+import { canonicalizeSvg, NORMALIZER_BUILD, SvgNormalizationError, normalizationFor } from '../../shared/svg/index.js'22 33 const CACHE_MAX_AGE = 1_80044 const CACHE_SCHEMA = '1'@@ -151,7 +151,7 @@ async function cacheKey(request: RenderRequest, descriptor: BrowserUnitDescripto
151151 let binary = ''152152 for (const byte of new Uint8Array(digest)) binary += String.fromCharCode(byte)153153 const encoded = btoa(binary).replaceAll('+', '-').replaceAll('/', '_').replace(/=+$/, '')154- return new Request(`https://diagramzip-browser-unit-cache.invalid/${CACHE_SCHEMA}/${descriptor.id}/${descriptor.build}/${encoded}`)154+ return new Request(`https://diagramzip-browser-unit-cache.invalid/${CACHE_SCHEMA}/${NORMALIZER_BUILD}/${descriptor.id}/${descriptor.build}/${encoded}`)155155 }156156 157157 function identityHeaders(descriptor: BrowserUnitDescriptor, cache: 'HIT' | 'MISS'): Headers {