MCPcopy
hub / github.com/github/docs / assetPreprocessing

Function assetPreprocessing

middleware/asset-preprocessing.js:13–26  ·  view source on GitHub ↗
(req, res, next)

Source from the content-addressed store, hash-verified

11const regex = /\/cb-\d+\//
12
13export default function assetPreprocessing(req, res, next) {
14 if (req.path.startsWith('/assets/')) {
15 // We're only confident enough to set the *manual* surrogate key if the
16 // asset contains the cache-busting piece.
17 if (regex.test(req.url)) {
18 // We remove it so that when `express.static()` runs, it can
19 // find the file on disk by its original name.
20 req.url = req.url.replace(regex, '/')
21 // The Cache-Control is managed by the configuration
22 // for express.static() later in the middleware.
23 }
24 }
25 return next()
26}

Callers

nothing calls this directly

Calls 1

nextFunction · 0.50

Tested by

no test coverage detected