Skip to content

Commit 2c28f47

Browse files
authoredFeb 4, 2022
Merge pull request #15085 from github/repo-sync
repo sync
2 parents e73e74f + f9895c6 commit 2c28f47

File tree

6 files changed

+31
-6
lines changed

6 files changed

+31
-6
lines changed
 
45.5 KB
Loading

Diff for: ‎content/organizations/managing-organization-settings/managing-the-forking-policy-for-your-organization.md

+1
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ If you allow forking of private{% ifversion ghes or ghec or ghae %} and internal
2323

2424
{% data reusables.profile.access_org %}
2525
{% data reusables.profile.org_settings %}
26+
{% data reusables.profile.org_member_privileges %}
2627
1. Under "Repository forking", select **Allow forking of private {% ifversion ghec or ghes or ghae %}and internal {% endif %}repositories**.
2728

2829
{%- ifversion fpt %}

Diff for: ‎data/reusables/profile/org_member_privileges.md

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
3. Under "Access", click **Member privileges**.
2+
![Screenshot of the member privileges tab](/assets/images/help/organizations/member-privileges.png)

Diff for: ‎middleware/index.js

+11-5
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ import handleCsrfErrors from './handle-csrf-errors.js'
1515
import compression from 'compression'
1616
import {
1717
setDefaultFastlySurrogateKey,
18-
setManualFastlySurrogateKey,
18+
setManualFastlySurrogateKeyIfChecksummed,
1919
} from './set-fastly-surrogate-key.js'
2020
import setFastlyCacheHeaders from './set-fastly-cache-headers.js'
2121
import catchBadAcceptLanguage from './catch-bad-accept-language.js'
@@ -115,15 +115,21 @@ export default function (app) {
115115

116116
app.use(favicon)
117117

118+
// Any `/assets/cb-*` request should get the setManualFastlySurrogateKey()
119+
// middleware, but it's not possible to express such a prefix in
120+
// Express middlewares. Because we don't want the manual Fastly
121+
// surrogate key on *all* /assets/ requests.
122+
// Note, this needs to come before `assetPreprocessing` because
123+
// the `assetPreprocessing` middleware will rewrite `req.url` if
124+
// it applies.
125+
app.use(setManualFastlySurrogateKeyIfChecksummed)
126+
118127
// Must come before any other middleware for assets
119128
app.use(archivedAssetRedirects)
120129

121130
// This must come before the express.static('assets') middleware.
122131
app.use(assetPreprocessing)
123-
// By specifying '/assets/cb-' and not just '/assets/' we
124-
// avoid possibly legacy enterprise assets URLs and asset image URLs
125-
// that don't have the cache-busting piece in it.
126-
app.use('/assets/cb-', setManualFastlySurrogateKey)
132+
127133
app.use(
128134
'/assets/',
129135
express.static('assets', {

Diff for: ‎middleware/set-fastly-surrogate-key.js

+7
Original file line numberDiff line numberDiff line change
@@ -32,3 +32,10 @@ export function setDefaultFastlySurrogateKey(req, res, next) {
3232
res.set(KEY, SURROGATE_ENUMS.DEFAULT)
3333
return next()
3434
}
35+
36+
export function setManualFastlySurrogateKeyIfChecksummed(req, res, next) {
37+
if (req.path.startsWith('/assets/cb-')) {
38+
return setManualFastlySurrogateKey(req, res, next)
39+
}
40+
return next()
41+
}

Diff for: ‎tests/rendering/server.js

+10-1
Original file line numberDiff line numberDiff line change
@@ -1034,7 +1034,16 @@ describe('static routes', () => {
10341034
expect(res.headers['set-cookie']).toBeUndefined()
10351035
expect(res.headers['cache-control']).toContain('public')
10361036
expect(res.headers['cache-control']).toMatch(/max-age=\d+/)
1037-
expect(res.headers['surrogate-key']).toBeTruthy()
1037+
expect(res.headers['surrogate-key']).toBe(SURROGATE_ENUMS.MANUAL)
1038+
})
1039+
1040+
it('no manual surrogate key for /assets requests without caching-busting prefix', async () => {
1041+
const res = await get('/assets/images/site/be-social.gif')
1042+
expect(res.statusCode).toBe(200)
1043+
expect(res.headers['set-cookie']).toBeUndefined()
1044+
expect(res.headers['cache-control']).toContain('public')
1045+
expect(res.headers['cache-control']).toMatch(/max-age=\d+/)
1046+
expect(res.headers['surrogate-key']).toBe(SURROGATE_ENUMS.DEFAULT)
10381047
})
10391048

10401049
it('serves schema files from the /data/graphql directory at /public', async () => {

0 commit comments

Comments
 (0)
Please sign in to comment.